feat(redux): Make reducers hot-reloadable
This commit is contained in:
@ -9,5 +9,12 @@ const sagaMiddleware = createSagaMiddleware();
|
|||||||
export const createStore = () => {
|
export const createStore = () => {
|
||||||
const store = reduxCreateStore(rootReducer, applyMiddleware(sagaMiddleware));
|
const store = reduxCreateStore(rootReducer, applyMiddleware(sagaMiddleware));
|
||||||
sagaMiddleware.run(rootSaga);
|
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;
|
return store;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user