Simple, small and dependency free redux state to local storage on reduce layer.
npm i local-redux-storage
For all state.
import { createStore, combineReducers } from 'redux';
import storage from 'local-redux-storage';
const rootReducer = combineReducers({ ...reducers })
const store = createStore(storage(rootReducer))
For one reducer state.
import { createStore, combineReducers } from 'redux';
import storage from 'local-redux-storage';
const exampleReducer = (state = {}, action) => state
const reducer = storage(exampleReducer, 'exampleReducerKey')
const rootReducer = combineReducers({
reducer,
...otherReducers
})
const store = createStore(storage(rootReducer))
Example project in example folder. Also live on https://local-redux-storage-example.netlify.app/.
ISC