redux-store-persist
v0.1.1
Published
Persist a Redux Store to local storage.
Downloads
7
Readme
redux-store-persist
Persist a Redux Store to localStorage.
Installation
$ npm install redux-store-persist
Usage
import persistStore from 'redux-store-persist'
const { loadState, persistState } = persistStore('storageKey')
const store = createStore(
reducer,
loadState() // Initialize store with saved state, if it exists
)
persistState(store) // Save state to localStorage on change
Persisting just a part of a store
persistState(store, (state) => {
// Pass a callback that returns the parts of your store that you want to
// persist to localStorage
return {
auth {
user: state.auth.user
}
}
})