react-loading-status-mixin

0.1.3 • Public • Published

react-loading-status-mixin

get the loading status of the component tree

Usage

var LoadingStatusMixin = require('react-loading-status-mixin');
 
React.createClass({
  mixins: [LoadingStatusMixin],
  componentWillMount: function() {
    var self = this;
    request.get('/api', function(res) {
      self.setState({data: res});
 
      // tell the mixin the component has loaded its data
      self.setIsLoaded(true);
    });
  },
  render: function() {
    // compute the className based on the loaded status
    var className = this.isLoaded() ? 'loaded' : 'loading';
 
    return (
      React.DOM.div({className: className})
    );
  }
});

API

setIsLoaded(isLoaded)

Set the loaded status for the component

isLoaded()

Get the loaded status for the component, including all of the children

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.3
    12
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.3
    12
  • 0.1.2
    3
  • 0.1.1
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i react-loading-status-mixin

Weekly Downloads

7

Version

0.1.3

License

MIT

Last publish

Collaborators

  • camshaft