A redux middleware for storing redux actions in sessionStorage
- key - key to store JSON array of actions as in sessionStorage
- transform - a function to transform action before storing Note : I reccomend using
Object.assign
or something similar before doing any modifcation to the data as this could adverse effects on your application. the data returned here will not be the action that is passed to next, the action that comes in will be passed, but as this is a plain object and not immutable, modifcations will have side effects. The transform function receives the action as it's first argument andgetState
as the second - limit - a limit on the number of items to store, defaults to no limit
import reduxSessionStorage from "redux-session-storage";
const sesionStorageRecord = reduxSessionStorage({key: "myKey"});
const createStoreWithMiddleware = applyMiddleware(sessionStorageRecord)(createStore);
We also include a function getActions(key)
that will return an array of stored actions.
npm i redux-session-storage --save