Created
June 21, 2016 12:40
-
-
Save johnrhampton/e182bcfcfca14252c60495d7c0bbf4cd to your computer and use it in GitHub Desktop.
/common/stores/main.store.js
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
'use strict'; | |
import {createStore, applyMiddleware, compose} from 'redux'; | |
import thunkMiddleware from 'redux-thunk'; | |
import createLogger from 'redux-logger'; | |
import rootReducer from '../reducers'; | |
import {ENV_TYPE} from '../constants/environment'; | |
export let createStores = (initialState) => { | |
const store = createStore( | |
rootReducer, | |
initialState, | |
compose( | |
applyMiddleware(thunkMiddleware, createLogger()), | |
window.devToolsExtension ? window.devToolsExtension() : f => f | |
) | |
); | |
if (module.hot && ENV_TYPE === 'local') { | |
module.hot.accept('../reducers', () => { | |
const nextRootReducer = require('../reducers').default; | |
store.replaceReducer(nextRootReducer); | |
}); | |
} | |
return store; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment