Last active
September 30, 2016 17:40
-
-
Save ruandao/008beca18857d6e532683fa01dceb2bb to your computer and use it in GitHub Desktop.
redux store file
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, combineReducers, compose, applyMiddleware } from 'redux'; | |
import ReduxThunk from 'redux-thunk'; | |
import { routerMiddleware } from 'react-router-redux'; | |
import { hashHistory } from 'react-router'; | |
import * as Reducers from '../reducers'; | |
export default function configureStore(initialState) { | |
const store = createStore( | |
combineReducers(Reducers), | |
initialState, | |
compose( | |
applyMiddleware(routerMiddleware(hashHistory), ReduxThunk), | |
window.devToolsExtension ? window.devToolsExtension() : f => f | |
) | |
); | |
if (module.hot) { | |
// Enable Webpack hot module replacement for reducers | |
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