21 lines
651 B
JavaScript
21 lines
651 B
JavaScript
import { createStore as reduxCreateStore, applyMiddleware } from 'redux';
|
|
import createSagaMiddleware from 'redux-saga';
|
|
|
|
import rootReducer from './rootReducer';
|
|
import rootSaga from './rootSaga';
|
|
|
|
const sagaMiddleware = createSagaMiddleware();
|
|
|
|
export const createStore = () => {
|
|
const store = reduxCreateStore(rootReducer, applyMiddleware(sagaMiddleware));
|
|
sagaMiddleware.run(rootSaga);
|
|
if (module.hot) {
|
|
// Enable Webpack hot module replacement for reducers
|
|
module.hot.accept('./rootReducer', () => {
|
|
const nextRootReducer = require('./rootReducer');
|
|
store.replaceReducer(nextRootReducer);
|
|
});
|
|
}
|
|
return store;
|
|
};
|