0.1.6 • Published 6 years ago
dynamic-redux v0.1.6
Dynamic redux
With dynamic redux you can inject your reducers on the fly
Installation
nikandlv@nikandlv.ir:~$ npm install redux react-redux redux-thunkThen 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