简体   繁体   English

React Native Expo 建设非常缓慢

[英]React Native Expo building very slowly

I've recently noticed my build time has increased considerably, sometimes taking a full minute to load.我最近注意到我的构建时间显着增加,有时需要一整分钟才能加载。 On the console I still see "Building JavaScript bundle: finished" fairly quickly but the screen takes much longer to refresh.在控制台上,我仍然相当快地看到“Building JavaScript bundle: finished”,但屏幕刷新时间要长得多。 Is there a reason something like this would be happening?有没有理由会发生这样的事情?

Try using Expo in a Simulator on your development machine and determine if it is taking as long as on your device:尝试在您的开发机器上的模拟器中使用 Expo 并确定它是否花费与您的设备一样长的时间:

  • If it is faster than on your test device, then you should check the network connection on your test device如果它比您的测试设备快,那么您应该检查您的测试设备上的网络连接
  • If it is as slow as on the test device, then you could try to remove node_modules and reinstall them with 'npm install' or 'yarn'.如果它和测试设备一样慢,那么您可以尝试删除 node_modules 并使用“npm install”或“yarn”重新安装它们。 Expo will be redownloaded aswell as all other packages. Expo 将与所有其他包一起重新下载。

In my case, it was a different solution.就我而言,这是一个不同的解决方案。

I followed the instructions given by jimmylee on the Expo SDK forums , which say:我按照jimmylee 在 Expo SDK 论坛上给出的说明进行操作,其中说:

If you are behind a VPN, try disabling the VPN.如果您使用 VPN,请尝试禁用 VPN。

If you are using windows 10, run CMD on your machine and type ipconfig.如果您使用的是 Windows 10,请在您的计算机上运行 CMD 并键入 ipconfig。 Take a look at the first Ethernet Adapter.看看第一个以太网适配器。 If it doesn't say Ethernet Adapter Ethernet it means Expo is taking the IP address of something else.如果它没有说 Ethernet Adapter Ethernet,则意味着 Expo 正在使用其他东西的 IP 地址。

To fix this, go to network connections and disable the adapter that it should not be pointing at.要解决此问题,请转到网络连接并禁用它不应指向的适配器。

Connect your computer to the network and your phone to the same network.将您的计算机连接到网络,并将您的手机连接到同一网络。 Restart Expo.重启世博会。

So, go to Settings > Network & Internet.因此,转到“设置”>“网络和 Internet”。

Click Change Adapter Options:单击更改适配器选项:

单击更改适配器选项

Then disable the unneeded Ethernet:然后禁用不需要的以太网:

然后禁用不需要的以太网

Then restart Expo.然后重启世博会。

If the connection is made but bundle building is very slow - Try disconnecting from the network both devices, the system and the mobile, and reconnect.如果已建立连接但捆绑构建速度非常慢 - 尝试断开两个设备(系统和移动设备)的网络连接,然后重新连接。 Also, don't forget to clear the 'recently in development' projects and start the project again.另外,不要忘记清除“最近开发中”的项目并重新启动该项目。 It will certainly increase the speed of building by far, especially for windows it works very well.到目前为止,它肯定会大大提高构建速度,尤其是对于 Windows,它运行得非常好。

I was going through the same problem.我遇到了同样的问题。

I used expo on multiple devices and clearly it depends on the device also, ie, whether it is able to handle it or not.我在多个设备上使用了 expo,显然它也取决于设备,即它是否能够处理它。

Second, for the slow device, i came up with a solution.其次,对于慢速设备,我想出了一个解决方案。

I just turned off the fast Refresh .我刚刚关闭了fast Refresh

Fast Refresh keeps a watch on the development side and keeps reloading whenever we make a change. Fast Refresh在开发方面保持监视,并在我们进行更改时不断重新加载。

By deactivating it, we need to refresh the app on our own.通过停用它,我们需要自己刷新应用程序。 But this helped me.但这对我有帮助。

Due to multiple refreshes and continuous bundling, expo gets slow (as per me) thus disabling this feature may help (infact helped me a lot).由于多次刷新和连续捆绑,世博会变慢(对我来说)因此禁用此功能可能会有所帮助(实际上对我帮助很大)。

STEPS TO DO THAT;这样做的步骤;

In your expo go app, shake your device.在您的 expo go 应用程序中,摇动您的设备。 An option panel will open.将打开一个选项面板。

There will be an option to disable fast refresh .将有一个选项可以disable fast refresh Simply click that and you are done.只需单击它即可完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM