redux replaceReducer似乎不适用于HMR

即时配置开发环境react-hot-loaderHMR是正常工作。我添加下面的配置redux redux replaceReducer似乎不适用于HMR

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)

})

}

当我改变减速文件,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.

但状态没有改变它的价值依然是初始价值。

回答:

在你的configuration.js中,你有导入'./reducers/index.js'吗?

以上是 redux replaceReducer似乎不适用于HMR 的全部内容, 来源链接: utcz.com/qa/257272.html

回到顶部