redux-state-cache
cache component state into redux store
Install
yarn add redux-state-cache
Usage
// createStore.js
import { cacheReducer } from 'redux-state-cache'
// ...
const reducerWithCache = cacheReducer(rootReducer)
const store = createStore(
reducerWithCache
)
// ...
// componet.js
import { stateCache } from 'redux-state-cache'
@stateCache(
'A_STATE_CACHE',
(state, cache) => ({
...state,
...cache
}),
(state) => state
)
Class A extends React.Componet {
state = {
a: 1
}
}