Every time when store change occurs, specified field automatically write to localStorage
npm i sync-redux-with-localstorage -D
state.cats = [
{
name: 'Fat Cat',
id: 1,
},
{
name: 'Good Cat',
id: 2,
},
];
const syncInterface = {
cats: {
id: true,
},
}
import syncReduxWithLocalstorage from 'sync-redux-with-localstorage';
export default createStore(
rootReducer,
composeWithDevTools(applyMiddleware(thunk, syncReduxWithLocalstorage(syncInterface))),
);
reduxLocalStorage: "{ "cats" : [{ "id": "1" }, { "id": "2" }]}"