dynamic-redux
v0.1.6
Published
With dynamic redux you can inject your reducers on the fly
Downloads
38
Maintainers
Readme
Dynamic redux
With dynamic redux you can inject your reducers on the fly
Installation
[email protected]:~$ npm install redux react-redux redux-thunk
Then simply copy Data folder into your project
Setup
Import it
import ReduxProvider from './Data/ReduxProvider'Wrap your root component or any base component
ReactDOM.render(
<ReduxProvider>
<Application />
</ReduxProvider>, document.getElementById('root'));Injecting a reducer
Import the store and a reducer
import CounterReducer from './Data/Reducers/CounterReducer'
import Store from './Data/Store'Inject your reducer
Store.injectReducer('CounterReducer',CounterReducer)injectReducer takes two parameters a key and the reducer
Use withDynamic builder
using withDynamic builder you can easily access your reducers and actions in your components
import withDynamic from './Data/withDynamic';
export default withDynamic(MyComponent)
.injectAction('name', func)
.injectReducer('CounterReducer')
.build()there are 2 main functions
injectAction which takes function name and the action and injects it into your component props
injectReducer which takes a reducer name and injcets it into your component props
