How do you debug React Native?

后端 未结 30 2538
无人共我
无人共我 2020-11-27 10:19

How does one debug their React code with React Native while the app is running in app simulator?

相关标签:
30条回答
  • 2020-11-27 10:27

    If you want to enable debugging by default:

    import { NativeModules } from 'react-native';
    
    if (__DEV__) {
      NativeModules.DevSettings.setIsDebuggingRemotely(true)
    }
    

    To get this working on Android:

    npm install --save react-native-devsettings-android
    react-native link react-native-devsettings-android
    

    Reference: Launch a React Native app with “Debug JS Remotely” enabled by default

    0 讨论(0)
  • 2020-11-27 10:27

    There is also a very good debuger name Reactotron. https://github.com/infinitered/reactotron

    You don't have to be in debug mode to see some data value and there is a lot of option.

    go have a look that is really usefull. ;)

    0 讨论(0)
  • 2020-11-27 10:28

    You can use Safari to debug the iOS version of your app without having to enable "Debug JS Remotely", Just follow the following steps:

    1. Enable Develop menu in Safari: Preferences → Advanced → Select "Show Develop menu in menu bar"
    2. Select your app's JSContext: Develop → {Your Simulator} → Automatically Show Web Inspector for JS JSContext
    3. Safari's Web Inspector should open which has a Console and a Debugger
    
    0 讨论(0)
  • 2020-11-27 10:30

    For an Android App, if you're using Genymotion you can toggle the menu by pressing CMD + m, but you may have to enable it in the menu by doing this.

    • Untick widget
    • Enable it by CMD + m click on debug in chrome
    0 讨论(0)
  • 2020-11-27 10:30

    Very simple just two commands

    For IOS $ react-native log-ios
    For Android $ react-native log-android
    
    0 讨论(0)
  • 2020-11-27 10:30

    This is the alternate way to use react native debugger application.

    you can download application using below link it's very good application for managing redux store along with the source code.

    react-native-debugger

    as well now a days you may directly use below link for help you out.

    chrome-developer-tools

    0 讨论(0)
提交回复
热议问题