static-cms/src/store/configureStore.js

21 lines
725 B
JavaScript
Raw Normal View History

2016-09-13 18:05:20 +02:00
import { createStore, applyMiddleware, compose } from 'redux';
2016-02-25 00:45:56 -08:00
import thunkMiddleware from 'redux-thunk';
2016-09-13 18:05:20 +02:00
import reducer from '../reducers/combinedReducer';
2016-02-25 00:45:56 -08:00
2016-09-13 18:05:20 +02:00
export default function configureStore(initialState) {
const store = createStore(reducer, initialState, compose(
applyMiddleware(thunkMiddleware),
window.devToolsExtension ? window.devToolsExtension() : f => f
));
2016-02-25 00:45:56 -08:00
if (process.env.NODE_ENV !== 'production' && module.hot) {
2016-09-13 18:05:20 +02:00
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers/combinedReducer', () => {
const nextReducer = require('../reducers/combinedReducer') // eslint-disable-line
store.replaceReducer(nextReducer);
});
}
2016-02-25 00:45:56 -08:00
2016-09-13 18:05:20 +02:00
return store;
}