What is “Debug JS Remotely” doing?

社会主义新天地 提交于 2019-12-13 02:27:05

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!