1.3.2 • Published 7 years ago

react-redux-loadmask v1.3.2

Weekly downloads
24
License
MIT
Repository
github
Last release
7 years ago

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:

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 ImportImmutable.js Import *
<Loadmask />react-redux-loadmaskreact-redux-loadmask/immutable
loadmaskReducerreact-redux-loadmaskreact-redux-loadmask/immutable
showLoadmaskreact-redux-loadmaskN/A
hideLoadmaskreact-redux-loadmaskN/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>
        )
      }
    }
  2. 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
    })
  3. 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())
  4. 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>
1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago