0.0.7 • Published 6 years ago

@pinyin/react-many-redux v0.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

react-many-redux

Redux stores with the new Context API.

Install

npm install @pinyin/react-many-redux

TypeScript should be supported out of the box.

Usage

import {createStoreContext} from '@pinyin/react-many-redux'
import {createStore} from 'redux'

const {Provider, Consumer} = createStoreContext({counter: 0})
const store = createStore()  // create a redux store

<Provider store={store}>
{/*...use store in descendants */}
    <Consumer distinct={(prev, curr)=> /* Optional. Receives two states, returns a boolean which indicates whether children should be updated */}>
    {
        ({state, dispatch})=> {
            // state: store state
            // dispatch: store.dispatch, dispatch action to store
        }
    }
    </Consumer>
</Provider>

see test for a more complete example.

Notice

This project is in early development.

License

MIT