Created
October 21, 2017 04:21
-
-
Save justincorrigible/530631c07c3803c1eabb731b692ed0c9 to your computer and use it in GitHub Desktop.
This file contains 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, applyMiddleware} from 'redux'; | |
import {routerMiddleware} from 'react-router-redux'; | |
import {composeWithDevTools} from 'redux-devtools-extension'; | |
import {persistStore, autoRehydrate} from 'redux-persist'; | |
import {createFilter} from 'redux-persist-transform-filter'; | |
// TODO crosstab persistance sync | |
//import crosstabSync from 'redux-persist-crosstab'; | |
import createHistory from 'history/createBrowserHistory'; | |
import localForage from 'localforage'; | |
import thunk from 'redux-thunk'; | |
import freeze from 'redux-freeze'; | |
import {rootReducer} from './reducers'; | |
const history = createHistory(); | |
const configureStore = (initialState) => { | |
const store = createStore( | |
rootReducer, | |
initialState, | |
composeWithDevTools( | |
applyMiddleware( | |
thunk, | |
freeze, | |
routerMiddleware(history) | |
), | |
autoRehydrate() | |
) | |
); | |
const UIStateTransform = createFilter( | |
'uiState', [ | |
'nightMode', | |
] | |
); | |
const persistor = persistStore(store, { | |
transforms: [UIStateTransform], | |
storage: localForage, | |
whitelist: 'uiState' | |
}); | |
//crosstabSync(persistor); | |
// if(__DEV__) { | |
if(module.hot) { | |
module.hot.accept(rootReducer, () => | |
store.replaceReducer(rootReducer) | |
); | |
} | |
// } | |
store.history = history; | |
store.persistor = persistor; | |
return store; | |
}; | |
export default configureStore; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment