0.1.1 • Published 8 years ago
redux-store-persist v0.1.1
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
}
}
})