Created
February 17, 2018 15:09
-
-
Save aofleejay/b6848b0498a034a863cb925370de1024 to your computer and use it in GitHub Desktop.
Config redux store with local storage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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