Created
September 14, 2015 20:18
-
-
Save jhsu/a11eb0c172526ed93250 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 thunkMiddleware from 'redux-thunk'; | |
import apiMiddleware from '../middleware/api'; | |
import loggerMiddleware from 'redux-logger'; | |
import rootReducer from '../reducers'; | |
const createStoreWithMiddleware = applyMiddleware( | |
thunkMiddleware, | |
apiMiddleware, | |
loggerMiddleware | |
)(createStore); | |
export default function configureStore(initialState) { | |
const store = createStoreWithMiddleware(rootReducer, initialState); | |
if (module.hot) { | |
// Enable Webpack hot module replacement for reducers | |
module.hot.accept('../reducers', () => { | |
const nextRootReducer = require('../reducers'); | |
store.replaceReducer(nextRootReducer); | |
}); | |
} | |
return store; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
taken from https://github.com/rackt/redux/blob/master/examples/real-world/store/configureStore.js#L16-L22