Adding a local reducer can be very verbose with libraries like recompose, the goal of this library is to reduce boilerplate when creating a local reducer.
This module is distributed via npm which is bundled with node and
should be installed as one of your project's dependencies
:
npm install --save react-redux-local
yarn add react-redux-local
import LocalReducer from 'react-redux-local'
const actions = {
doSomething: () => ({ type: 'SOMETHING' })
}
// https://github.com/redux-saga/redux-saga
function * saga () {
yield takeEvery('SOMETHING', () => console.log('Action with type SOMETHING was triggered'))
}
// https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md#windowdevtoolsextensionconfig
const devToolsOptions = {}
const MyComponent = () => (
<LocalReducer
reducer={reducer}
actions={actions}
sagas={[saga]}
devToolsOptions={devToolsOptions}
render={(state, actions, dispatch) => {
// state = redux state
// actions = binded actions (no need to dispatch)
// dispatch = optional dispatch function, if you need a more complex workflow
}}
/>
)
Michael Jackson - Never Write Another HoC
local-react-redux local-react-redux-saga react-local-reducer
Thanks goes to these people:
Flávio Carvalho |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT