npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-redux-loadmask

v1.3.2

Published

A React / Redux Loading Mask

Downloads

61

Readme

react-redux-loadmask

About

If you're looking for a simple to use "loading mask" to be used with your React + Redux application, look no further! This module provides you with:

  • a reducer, a couple of actions, and the <Loadmask /> component itself
  • the ability to trigger said actions anywhere in your app to show or hide the loadmask
  • support for rendering a single child, with a simple prop to change the background color
Peer dependencies are currently as follows:
  • immutable
  • react
  • react-redux
  • immutable [ optional - depends on your app state ]

Installation

NPM

$ npm install react-redux-loadmask --save

Yarn

$ yarn add react-redux-loadmask

Usage

Using the <Loadmask /> component provided by this module is simple.

There are a few 'parts' provided out of the box for you:

| | ES6 Import | Immutable.js Import * | |---------------------|------------------------|----------------------------------| | <Loadmask /> | react-redux-loadmask | react-redux-loadmask/immutable | | loadmaskReducer | react-redux-loadmask | react-redux-loadmask/immutable | | showLoadmask | react-redux-loadmask | N/A | | hideLoadmask | react-redux-loadmask | N/A |

* The Loadmask component and its corresponding reducer are available in the Immutable.js flavors, as indicated above.

Example

  1. Import the component and render it within a higher order container. This could be your app's "Main.js" or "App.js".
import React, { Component } from 'react'
import Loadmask from 'react-redux-loadmask'

export default class ExampleApp extends Component {
  // ... Let's skip to the fun part

  render () {
    return (
      <div>
        <Loadmask />
        // ... Your other components
      </div>
    )
  }
}
  1. Import and combine loadmaskReducer into your app's "root reducer" (top level). Keep in mind that only the <Loadmask /> component and this function have and require its Immutable variants if your state is utilizing it. (see table above)
import { loadmaskReducer } from 'react-redux-loadmask'

export default combineReducers({
  loadmaskReducer,
  // ... Your other reducers
})
  1. Use the actions showLoadmask and hideLoadmask provided. They utilize namespaced "types", inspired by the react-redux-router library. Examples of how you can use them are shown below.
  import { showLoadmask, hideLoadmask } from 'react-redux-loadmask'

  // You can then dispatch to either show or hide the loadmask from anywhere!
  dispatch(showLoadmask())
  import { loadmaskActions } from 'react-redux-loadmask'

  // The same methods are available for you off the `loadmaskActions` import
  dispatch(loadmaskActions.hideLoadmask())
  1. And that's it! By utilizing the provided reducer and simply rendering the <Loadmask /> component, you're now able to conveniently manage this top-level UI to enhance browsing experience during large data fetches, page transitions, or even preventing access to a view.

Rendering Children

In the likely event that you'll want to render your own child in the middle of the Loadmask, you can do so by simply wrapping the intended child with the Loadmask tags.

  <Loadmask>
    <ExampleChild />
  </Loadmask>