store-state-mixin
THIS REPO IS ABANDONED
With so many better and amazing tools available to pass down state in React today, this is rather pointless to use.
A React mixin for easily adding (flux) stores state to a component.
- Efficiently updates component state, only for the stores that changed
- Installs listeners on componentDidMount
- Removes listeners on componentWillUnmount
- No dependencies
- Made for Alt, but might be useful with some other React stores as well
--
Usage:
Install with npm:
npm install --save store-state-mixin
A flux example with alt using store-state-mixin:
// TopLevelComponent.js // require the mixin and child componentsconst StoreStateMixin = ;const SomeChildComponent = ;const OtherChildComponent = ; // create a stores init object for the mixin, using key names that will be// used as keys in this component's state and child components propsconst stores= someStore : otherStore : ; const TopLevelComponent= React;;
In your child component:
// SomeChildComponent.js // get your actionsconst someActions= ; const SomeChildComponent= React;;
The store:
// someStore.js // refer to a alt instance and this store's actions;; { this; } { thisinfo= info; };
The actions:
// someActions.js { this; };
A single Alt instance:
// alt.jsconst alt= 'alt' ;
Just to complete the example:
// OtherChildComponent.js
// otherStore ; ;
--
Change log:
0.1.5:
- changes license to MIT
--
0.1.4:
- replaces map with map-x
--
0.1.3:
- added minified version
- updated the readme
- added example files
--
0.1.2:
- adds hasOwnProperty to object map
- adds es3 compatibility
license
MIT