1.0.2 • Published 8 years ago
redux-simple-localstorage v1.0.2
redux-simple-localstorage
Ridiculously simple implementation for serialising the entire Redux store to local storage and retrieving it on application restart.
Installation
npm install --save redux-simple-localstorage
Usage
The module exports a single function. Call that with the localStorage key, and you get an object with a read
and write
method:
import ReduxLocalstorage from "redux-simple-localstorage"
const {read,write} = ReduxLocalstorage("myKey");
Now use write
as a middleware and the result of read
as initial state when you define your store:
import { createStore, applyMiddleware } from "redux";
import ReduxLocalstorage from "redux-simple-localstorage"
const {read,write} = ReduxLocalstorage("myKey");
import rootReducer from "./reducers/index";
import initialState from "./initialstate";
const store = applyMiddleware(write)(createStore)(rootReducer, read() || initialState);
License
MIT