August 2017
Beginner
374 pages
10h 41m
English
Now that we have configured webpack and React to use hot reloading, there is just one thing missing—we need to integrate hot reloading into Redux. The idea is that, whenever the reducer code changes, the state will be recomputed. For this to be possible, Redux needs to know when the reducer code changes. We can give Redux a new reducer by calling store.replaceReducer().
Edit src/store/index.dev.js and replace the configureStore function with the following code:
export default function configureStore (initialState) { const store = createStore(appReducer, initialState, enhancer) if (module.hot) { module.hot.accept('../reducers/index', () => store.replaceReducer(require('../reducers/index').default) ) } return ...Read now
Unlock full access