问题
Can anyone explain how is it that running the app with "Debug JS Remotely" behaves differently than without it? Currently, my app seems to behave differently between these two modes.
To be specific, when my app is in "Debug JS Remotely", it can fire API requests and get responses successfully. When the app is not in "Debug JS Remotely", it's unable to fire API requests?
回答1:
The issue you're experiencing might be due to the different Javascript engines involved:
- When running on the device, your code will run on the JavascriptCore engine which is bundled with the RN app itself.
- When running the remote debugger, your code will run on Chrome's V8 engine, not on the device.
Different environments might behave differently. Take the following example from this article:
Without remote debugging:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // 02/12/17
With remote debugging:
new Date("2017-02-12 23:51:31")
.toLocaleDateString('en-US', { day: '2-digit', month: 'short' }) // Feb 12
For this reason, I prefer to sometimes use third-party implementations of some native features (like whatwg-fetch instead of using native fetch).
Resources:
- React Native Architecture - Javascript VM
回答2:
Hi as Explained by @Matei above The issue you're experiencing might be due to the different Javascript engines involved In my case code was running fine in debug mode but as soon i off debug mode screen get stuck
Solution:
So what worked for me was removing all the console.log from the file.
So just remove all the console.log from your code and it will work like a charm.
来源:https://stackoverflow.com/questions/52604343/what-is-debug-js-remotely-doing