Skip to content

Instantly share code, notes, and snippets.

@aofleejay
Created February 17, 2018 15:12
Show Gist options
  • Save aofleejay/c055fd3f2327215d2e617bcacebd798f to your computer and use it in GitHub Desktop.
Save aofleejay/c055fd3f2327215d2e617bcacebd798f to your computer and use it in GitHub Desktop.
Config store with redux-persist
import { createStore } from 'redux'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'
import rootReducer from '../reducers'
const persistConfig = {
key: 'root',
storage,
}
const persistedReducer = persistReducer(persistConfig, rootReducer)
export default () => {
let store = createStore(persistedReducer)
let persistor = persistStore(store)
return { store, persistor }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment