Decoupled redux, for react functional components.
npm install @hacknlove/reduxplusDecoupled redux, for react functional components.
``javascript
import React from 'react'
import ReactDOM from 'react-dom'
import store from 'reduxplus'
store.hydrate({
worldName: 'world'
foo: {
bar: {
buz: 42
}
}
})
store.setReducer((state, action) => {
if (action.type !== 'setWorld') {
return state
}
return {
...state,
worldName: action.worldName
}
})
function Example () {
const worldName = store.useRedux('worldName')
const theMeaningOfLife = store.useRedux('foo.bar.buz')
return (
ReactDOM.render(
document.querySelector('#root')
)
`API
can be dot-composed`javascript
const data = useRedux() // returns store.getState() and actualizes the component when data changesconst foobar = useRedux('foo.bar') // returns store.getState().foo.bar, and actualizes the component when that value changes
`$3
Set the store value
`javascript
// store.getValue() -> {foo: 'bar'}hydrate({
buz: 42
})
// store.getValue() -> {foo: 'bar', buz: 42}
hydrate({import { store, setReducer, setMiddleware, useRedux, hydrate } from 'reduxplus'
foo: 'foooo'
})
// store.getValue() -> {foo: 'foooo', buz: 42}
hydrate({
bar: 40
}, true)
// store.getValue() -> {bar: 42}
`subStores
test
`bash
git clone https://github.com/hacknlove/reduxplus.git
cd reduxplus
npm i
npm test
``