【发布时间】:2018-09-04 09:07:05
【问题描述】:
我在 Windows 10 和 Ubuntu 16.04 上尝试过。在这两种情况下,热重载仅适用于 jsx 中的更改,但不适用于我更改 javascript 中的变量或函数或其他内容时。热重载已启用。实时重新加载已禁用。当我在 Visual Studio 代码编辑器中保存更改时,虚拟设备 (android studio) 会重新加载,但更改不存在。 EXPO App中的物理设备上也是如此。
首先我没有安装守望者。 Hot Relaod 不工作。安装后 Hot Reload 也不行。
我使用 create-react-native-app 启动应用程序。它没有被弹出。
package.json:
{
"name": "NativeReduxSaga",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "25.0.0",
"react-native-debugger-open": "^0.3.17",
"react-native-scripts": "1.11.1",
"react-test-renderer": "16.2.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js",
"postinstall": "rndebugger-open --expo"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"@redux-offline/redux-offline": "^2.3.2",
"expo": "^25.0.0",
"prop-types": "^15.6.1",
"react": "16.2.0",
"react-native": "0.52.0",
"react-native-autocomplete-input": "^3.5.0",
"react-navigation": "^1.5.2",
"react-redux": "^5.0.7",
"redux": "^3.7.2",
"redux-devtools-extension": "^2.13.2",
"redux-logger": "^3.0.6",
"redux-observable": "^0.18.0",
"redux-promise-middleware": "^5.0.0",
"redux-saga": "^0.16.0",
"redux-thunk": "^2.2.0",
"rxjs": "^5.5.7"
}
}
守望者版本
{
"version": "4.9.1",
"buildinfo": "94e66865386e844f2cffe52e355a94c96562d2e3 2018-03-12T19:58:02.0000000Z"
}
节点版本 v6.13.1
我在这里读到一些文章,它可以帮助在 Windows 上提高 MAX_WAIT_TIME。但我没有 \node_modules\react-native\node_modules\node-haste\lib\FileWatcher\ index.js 文件。
为什么它也不能在 Ubuntu 上运行?
我真的需要守望者吗?应该如何配置?我的 .watchmanconfig 文件是一个空对象,例如 {}。
热重载通常与 create-react-native-app 一起使用吗?
有人知道我可以在这里尝试什么,以使热重载正常工作吗? 感谢您的帮助!
【问题讨论】:
-
使用实时重载更新变量
-
好的,谢谢!所以我必须在 live 或 hot reload 之间切换取决于改变变量或函数中的东西,或者只改变 jsx 和样式。
-
是的,实时重新加载可以做到这两点
-
好的,但是随着实时重新加载,整个应用程序的状态每次都会重新开始,不是吗?它不会记住更改前的状态
-
是的,它会重新加载所有状态
标签: react-native react-native-android create-react-native-app watchman hot-reload