怎么热重载应该在本机中起作用?

时间:2016-03-22 19:28:09

标签: react-native redux

Hot Reloading现已推出,但我遇到很多问题。

起初我的redux商店中有标准module.hot.accept("../reducers", () => {代码,但这导致了问题。在对该代码进行评论后,我开始获得Cannot read property 'length' of undefined

我创建了一个新项目react-native init test,每次更改文件时都会收到相同的错误。

ExceptionsManager.js:61 Cannot read property 'length' of undefined

项目中是否需要进行热重装工作?

更新

这仍然没有记录,造成的问题多于其价值。现在我正在使用redux-persist进行实时重新加载。

1 个答案:

答案 0 :(得分:5)

Facebook终于记录了如何使用热重新加载或热模块替换。

https://facebook.github.io/react-native/blog/2016/03/24/introducing-hot-reloading.html

api与Webpack略有不同

if (module.hot) {
    module.hot.accept(() => {
        const nextRootReducer = require("../reducers").default;
        store.replaceReducer(nextRootReducer);
    });
}