Skip to content

Instantly share code, notes, and snippets.

@ruandao
Last active September 30, 2016 17:40
Show Gist options
  • Save ruandao/008beca18857d6e532683fa01dceb2bb to your computer and use it in GitHub Desktop.
Save ruandao/008beca18857d6e532683fa01dceb2bb to your computer and use it in GitHub Desktop.
redux store file
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