gpt4 book ai didi

react-native - 热重载在 native android 中不起作用

转载 作者:行者123 更新时间:2023-12-04 04:36:34 24 4
gpt4 key购买 nike

我在 Windows 10 和 Ubuntu 16.04 上尝试过。在这两种情况下,热重载仅适用于 jsx 中的更改,但不适用于我在 javascript 中更改变量或函数或其他内容时。热重载已启用。实时重新加载已禁用。当我在 Visual Studio 代码编辑器中保存更改时,虚拟设备 (android studio) 会重新加载,但更改不存在。 EXPO App中的物理设备也是如此。

首先我没有安装watchman。 Hot Relaod 不工作。安装后,热重载也不起作用。

我使用 create-react-native-app 启动应用程序。它不会被弹出。

包.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 一起使用吗?

有谁知道我可以在这里尝试什么来使热重载工作?
感谢您的帮助!

最佳答案

实际上,Hot Reloading 和 Live Reloading 是有区别的。

热加载 是即时重新加载,同时保持应用程序的状态完好无损。但是,它只适用于 render方法并且仅在类 React.Component 和 Component 的扩展上触发

如:

class A extends Component ...
class B extends React.Component ...

实时重载 另一方面,重建您的应用程序并丢弃您的应用程序状态。它包括一切,从变量和方法到最简单的字符串。这就是为什么总是从应用程序的开始屏幕开始(因为状态丢失)。

希望能帮助到你!

关于react-native - 热重载在 native android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49487768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com