我在Windows 10和Ubuntu 16.04上尝试了它。在两种情况下,热重新加载仅适用于jsx更改,而不是当我更改javascript中的变量、函数或其他内容时。已启用热重新加载,禁用实时重新加载。当我保存Visual Studio Code编辑器中的更改时,虚拟设备(android studio)会重新加载,但更改并未生效。在EXPO应用程序中的物理设备上也是如此。
首先,我没有安装watchman,导致热重新加载无法正常工作。后来安装了watchman,但热重新加载仍然无法正常工作。
我使用create-react-native-app启动了该应用程序,且未进行过eject操作。
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"
}
Node版本 v6.13.1
我在这里读到一些文章,说在Windows上提高MAX_WAIT_TIME可能有所帮助。但是我没有一个\node_modules\react-native\node_modules\node-haste\lib\FileWatcher\ index.js文件。
为什么Ubuntu上也不起作用呢?
我真的需要watchman吗?应该如何配置?我的.watchmanconfig文件是一个空对象{}。
使用create-react-native-app时,热重载通常是否有效?
有人知道我可以尝试什么来让热重载工作吗?感谢您的帮助!