Skip to content

Instantly share code, notes, and snippets.

@jhsu
Created September 14, 2015 20:18
Show Gist options
  • Save jhsu/a11eb0c172526ed93250 to your computer and use it in GitHub Desktop.
Save jhsu/a11eb0c172526ed93250 to your computer and use it in GitHub Desktop.
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