I've configured a development environment with react-hot-loader
. HMR
is working normally and I've added the configuration below for redux
if (module.hot) {
// Enable Webpack hot module replacement for reducers
module.hot.accept('../reducers', () => {
console.log('reducers change')
const nextReducer = require('../reducers').default
store.replaceReducer(nextReducer)
})
}
when I change the reducer file, module.hot.accept
handler works and [HMR] seems to get the succeess info
[HMR] connected
[HMR] bundle rebuilding
[HMR] bundle rebuilt in 405ms
[HMR] Checking for updates on the server...
reducers change
[HMR] Updated modules:
[HMR] - ./src/reducers/testReducer.js
[HMR] - ./src/reducers/index.js
[HMR] App is up to date.
but the state is not changing, it's value is still the initial one.
in you configuration.js ,have you import './reducers/index.js'?