Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native behavior different in simulator / on device / with or without Chrome debugging

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?)

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.

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?

Thank you.

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.

like image 606
Lane Rettig Avatar asked Sep 25 '22 12:09

Lane Rettig


People also ask

How do you debug react in native simulator?

Debugging React Native Apps (Chrome only for now) or use the Shake Gesture. Enable Pause On Caught Exceptions for a better debugging experience. Press Command + Option + I to open the Chrome Developer tools, or open it via View -> Developer -> Developer Tools . You should now be able to debug as you normally would.

Does React Native use Chrome?

Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read this section to learn how.


1 Answers

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

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.

like image 98
filiphosko Avatar answered Oct 13 '22 18:10

filiphosko