react-redux-magic-reducer
React-redux bindings for redux-magic-reducer.
Why?
Setting up React with dynamic reducers is one of a time consuming task. While redux-magic-reducer simplifies it good enough, getting context and childContextsTypes right in first attempt is always a tricky task. To overcome that, this library provides a seamless way to get dynamic/async reducers up and running with no hassle.
Install
npm install --save redux-magic-reducer react-redux-magic-reducer
How to use
1. Create a Root of App using withProvider
import ReactDOM from 'react-dom'import withProvider createStore from 'react-redux-magic-reducer';import reducers from './reducers/index';import App from './App' let store = ; ReactDOM
2. Creating a connected component with dynamic reducer using magicConnect
import MagicComponent from './MagicComponent';import MagicActions from './actions/magic-actions';import Reducer from './reducer/magicReducer';import magicConnect from 'react-redux-magic-reducer';import bindActionCreators from "redux"; const mapStateToProps = state ownProps return counter : statedynamiccounter name : statedynamicname ; const mapDispatchToProps = dispatch return increaseCounter : decreaseCounter : ;mapStateToProps mapDispatchToPropsMagicComponent 'dynamic' Reducer;
For detailed example on how to use it, please take a look at example directory.
Upcoming/Under development
- React 16 context migration
- API Documentation
- Add more examples with different connect properties
- Add example of injection of context properties.
License
MIT © saurabhnemade