A redux middleware which saves a snapshot of the state to localStorage.
import {createStore, applyMiddleware} from "redux";
import saveState from "redux-save-state/localStorage";
import combinedReducers from "./reducer";
const createStoreWithMiddlewares
= applyMiddleware(saveState('appState'))(createStore);
const store = createStoreWithMiddlewares(combinedReducers);
// In React Component
store.dispatch(action);
console.log(localStorage.appState); // state as JSON string
import saveState from "redux-save-state/localStorage";
const key = "some_key_string";
const options = { ... };
const middleware = saveState(key, options);
Required. The key in localStorage to save state.
default state => state
.
Saves the value returned by filter
function.
default 0.
Delays setting the state to localStorage until debounce
milliseconds have elapsed since the last time the action was dispatched.
See also _.debounce.