configureStore.dev.js 759 B

12345678910111213141516171819202122232425
  1. import { createStore, applyMiddleware, compose } from 'redux';
  2. import thunkMiddleware from 'redux-thunk';
  3. import { initialState, rootReducer } from '../reducers/root';
  4. export default function configureStore() {
  5. /* eslint-disable no-underscore-dangle */
  6. const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  7. /* eslint-enable */
  8. const store = createStore(
  9. rootReducer,
  10. initialState,
  11. composeEnhancers(applyMiddleware(thunkMiddleware)),
  12. );
  13. if (module.hot) {
  14. // Enable Webpack hot module replacement for reducers
  15. module.hot.accept('../reducers/root', () => {
  16. const nextRootReducer = require('../reducers/root').default;
  17. store.replaceReducer(nextRootReducer);
  18. });
  19. }
  20. return store;
  21. }