mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-16 21:06:35 +08:00
feat(redux): Make reducers hot-reloadable
This commit is contained in:
parent
4f54803674
commit
68cdeea6ae
@ -9,5 +9,12 @@ 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;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user