2

我在使用 react hot loader 3 时遇到问题。

我的应用程序中的某些模块得到了热更新,有些则没有。我有一个文件夹(应用程序),其中包含我所有的组件。在这个文件夹中,我有 index.js,我从文件夹中导出所有模块。在文件夹中,我有index.js导出组件本身的文件。例子:

app/test包含test.jsindex.js app/test/index.js包含export test from ./test.js app/index.js包含export * as test from ./test

在我的应用程序的某个地方,我像这样导入这个测试应用程序import { test } from ../app

在这里,魔法出现了。hmr 不适用于 test.js。但是,如果我export * as test from ./test在其中添加注释app/index.js并直接导入我的测试组件,import test from ../app/test/test.js则 hmr 可以工作。我已经尝试修复它3天了。app/index.js被导入到我的routes.js文件中。这是唯一一个进口的地方。只有app文件夹中的所有组件都不会得到热更新,除非它工作正常。我试图用任何样板复制它,但没有成功。

在控制台中我看到

[WDS] App updated. Recompiling...
log-apply-result.js?d762:11 [HMR] The following modules couldn't be hot updated: (They would     need a full reload!)
log-apply-result.js?d762:18 [HMR] Nothing hot updated.
only-dev-server.js?2f87:49 [HMR] App is up to date.
client?e36c:37 [WDS] App updated. Recompiling...
client?e36c:37 [WDS] Nothing changed.
4

1 回答 1

1

问题在于文件夹的结构。循环依赖失败 hmr。修复它修复了问题。

于 2017-02-12T23:54:33.183 回答