React native - Programmatically check if in remote JS debugging is enabled

后端 未结 7 786
小蘑菇
小蘑菇 2021-02-01 19:04

On React-Native, how can I know if \"Debug JS Remotely\" is enabled?

I tried looking in RN docs and various NPM packages, but couldn\'t find out how...

7条回答
  •  一个人的身影
    2021-02-01 19:38

    So, any of the following answers didn't work for me...

    I found out that the location pathname changes to /debugger-ui on global object:

    if (global.location && global.location.pathname.includes('/debugger-ui')) {
      Alert.alert('Remote debug is on');
    } else {
      Alert.alert('Remote debug is off');
    }
    

    Working on RN 0.59.

提交回复
热议问题