redux-session-manager
Installation
npm i -S redux-session-manager
Usage
Create a persistent store by enchancing createStore
;;const createPersistentStore = createStore;// Pass along the same arguments you would have to createStoreconst store = ;
Applying enhancers
To apply enhancers, like applyMiddlware, pass it to the left of persistState in compose
const persistentStoreWithMiddleware = createStore
ImmutableJS
If you are using ImmutableJS via redux-immutable
for example, just change the import to
;
Options
Property | Type | Required? | Description |
---|---|---|---|
name | string | yes | This will be the key in sessionStorage for the serialized state |
exclude | array[string|array] | no | An array containing either a string representing the reducer to exclude, or an array of [reducerName, keyPaths] where keyPaths can be either a string for a direct property of the reducer, or an array representing the keyPath to the property to be excluded. |
Excluding parts of state
Use the exclude option to specify which properties you do not want to serialize to the store
Example
Here is an example using Redux Dev Tools Extension, redux-thunk, redux-logger;
;;;;; const composeEnhancers = window__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;const middleware = thunk logger ;const createPersistentStoreWithMiddleware = createStore; const store = ;