我使用react-hot-loader
配置开发环境,HMR
正常工作。我为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)
})
}
当我更改reducer文件时,module.hot.accept
处理程序工作,[HMR]似乎获得成功信息
[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.
但是状态没有改变,它的价值仍然是初始值。
答案 0 :(得分:0)