Skip to content

Instantly share code, notes, and snippets.

@aofleejay
Created February 17, 2018 15:09
Show Gist options
  • Save aofleejay/b6848b0498a034a863cb925370de1024 to your computer and use it in GitHub Desktop.
Save aofleejay/b6848b0498a034a863cb925370de1024 to your computer and use it in GitHub Desktop.
Config redux store with local storage
import { createStore } from 'redux'
import rootReducer from '../reducers'
import { loadState, saveState } from '../lib/localStorage'
const persistStore = loadState()
const store = createStore(rootReducer, persistStore)
store.subscribe(() => {
saveState(store.getState())
})
export default store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment