在模拟器/设备上/有或没有Chrome调试时,React Native行为会有所不同 [英] React Native behavior different in simulator / on device / with or without Chrome debugging

查看:216
本文介绍了在模拟器/设备上/有或没有Chrome调试时,React Native行为会有所不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个React Native应用程序(目前仅限iOS),我发现了一个非常讨厌的错误,只有当1.)在真实设备上运行时才能显示,以及2.)在没有Chrome调试的情况下运行。 (哎呀,对吧?)

I'm building a React Native app (currently iOS only) and I found a very nasty bug that only manifests itself when 1.) running on a real device, and 2.) running without Chrome debugging. (Ouch, right?)

我正在使用 react-native-router-flux 和标签,当我点击一个加载新标签路线的按钮( Actions.tabRouteName )时,屏幕变成空白。正如我所说,它在模拟器中运行良好,并且在我启用Chrome调试时在设备上运行良好。

I'm using react-native-router-flux with tabs and when I tap on a button that loads a new tab route (Actions.tabRouteName), the screen goes blank. As I said, it works fine in the simulator, and also, on the device when I enable Chrome debugging.

我试过的其他事情:在另一台设备上运行,重新加载JS ,在Xcode中重建应用程序。

Other things I tried: running on another device, reloading JS, rebuilding app in Xcode.

在这些不同的运行情况下,行为会有什么不同吗?

Any reason the behavior would be different in these different run cases?

谢谢你好。

更新:这似乎与动画和路由切换有关。我在此Github问题中发布了更多详细信息 。我还发现了其他人在调试这个Github问题时遇到类似问题的想法的轶事支持

Update: This appears to have something to do with animations and route switching. I posted more details in this Github issue. I also found anecdotal support for the idea that other people are encountering similar issues with debugging in this Github issue.

推荐答案


在这些不同的运行案例中,行为会有什么不同?

Any reason the behavior would be different in these different run cases?

这是因为当您在Chrome中使用远程调试时,它几乎在浏览器中运行RN应用程序(然后使用V8 JavaScript引擎) )并通过WebSockets与模拟器(或设备)通信。如果在没有启用远程调试的情况下运行,它将使用JavaScript Core。这些环境之间存在许多差异,这些差异可能会导致不一致,所以不要仅仅依靠启用JS调试来运行应用程序,它可能会给您带来错误错误或隐藏实际会导致实际设备出现问题的错误。

It's because when you use remote debugging in Chrome, it practically runs the RN app in the browser (it then uses the V8 JavaScript engine) and communicates with the simulator (or device) through WebSockets. When it runs without remote debugging enabled, it uses JavaScript Core. There are many differences between these environments and these can cause inconsistencies, so don't rely much on running your app only with JS debugging enabled, it can give you false errors or hide errors that would actually cause problems on a real device.

这篇关于在模拟器/设备上/有或没有Chrome调试时,React Native行为会有所不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆