Hot Reload在React-Native Android中不起作用

Hot Reload not working in react-native android

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

首先,我没有安装值班员。 Hot Relaod无法正常工作。安装后,热重装也不起作用。

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

package.json:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{
 "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"
  }
}

守望者版本

1
2
3
4
{
   "version":"4.9.1",
   "buildinfo":"94e66865386e844f2cffe52e355a94c96562d2e3 2018-03-12T19:58:02.0000000Z"
}

节点版本
v6.13.1

我在这里阅读了一些文章,它可以在Windows上提高MAX_WAIT_TIME的效率。但是我没有\\
ode_modules \\
真实的\\
ode_modules \\
ode-haste \\\\ lib \\\\ FileWatcher \\\\ index.js文件。

为什么它也不能在Ubuntu上运行?

我真的需要看守吗?应该如何配置?我的.watchmanconfig文件是一个空对象,例如{}。

热重装通常可以与create-react-native-app一起使用吗?

有人知道我可以在这里尝试些什么,以使热装工作正常吗?
感谢您的帮助!


实际上,热重装和实时重装之间是有区别的。

热重装是即时重装,同时保持应用程序状态不变。但是,它仅在render方法内部起作用,并且仅在类React.Component和Component

的扩展上触发

如:

1
2
class A extends Component ...
class B extends React.Component ...

另一方面,

实时重新加载,重新构建您的应用程序并放弃您的应用程序状态。它包括从变量和方法到最简单的字符串的所有内容。这就是为什么总是从应用程序的启动屏幕开始的原因(因为状态丢失了)。

希望有帮助!


n


我执行了以下步骤来解决此问题:

  • mkdir android / app / src / main / assets

  • react-native bundle --platform android --dev false --entry-file index.js --bundle-output android / app / src / main / assets / index.android.bundle --assets-dest android / app / src / main / res

  • 在模拟器中摇动android设备或cmd d,您将获得一个菜单。

  • 一旦启用和禁用热重装。

  • 清除在Dev设置中使用的IP地址->调试->调试服务器主机


    n


    n


    n


    n