React Native atob() / btoa() not working without remote JS debugging

前端 未结 3 756
灰色年华
灰色年华 2020-12-04 15:18

I have a testing app in react native, and all works fine when I have enabled the debug js remotely. It works fine in device (from XCode) and simulator, after run:

         


        
3条回答
  •  渐次进展
    2020-12-04 16:08

    The main part of your question has been answered, but I see there's still some uncertainty about why it works with remote debugging enabled.

    When debugging remotely, the JavaScript code is actually running in Chrome, and the diffs to the virtual dom are being communicated to the native app over a web socket.

    http://facebook.github.io/react-native/docs/javascript-environment

    atob and btoa are available in the context of the browser, and that's why it works there.

    When you stop debugging, though, the JavaScript is again interpreted in a process on your device or simulator, which doesn't have access to functions that are provided by the browser.

提交回复
热议问题