How to do logging in React Native?

前端 未结 30 3060
不思量自难忘°
不思量自难忘° 2020-11-30 17:08

How can I log a variable in React Native, like using console.log when developing for web?

相关标签:
30条回答
  • 2020-11-30 17:19

    Its so simple to get logs in React-Native

    Use console.log and console.warn

    console.log('character', parameter)
    
    console.warn('character', parameter)
    

    This log you can view in browser console. If you want to check device log or say production APK log you can use

    adb logcat
    
    adb -d logcat
    
    0 讨论(0)
  • 2020-11-30 17:19

    Use react native debugger for logging and redux store https://github.com/jhen0409/react-native-debugg

    Just download it and run as software then enable Debug mode from the simulator.

    It supports other debugging feature just like element in chrome developer tools, which helps to see the styling provided to any component.

    Last complete support for redux dev tools

    0 讨论(0)
  • 2020-11-30 17:20

    console.log() is the best and simple way to see your log on console when you use remote js debugger from your developer menu

    0 讨论(0)
  • 2020-11-30 17:21

    Pre React Native 0.29, run this in the console:

    adb logcat *:S ReactNative:V ReactNativeJS:V

    Post React Native 0.29, run:

    react-native log-ios

    or

    react-native log-android

    As Martin said in another answer.

    This shows all console.log(), errors, notes, etc. and causes zero slow down.

    0 讨论(0)
  • 2020-11-30 17:21

    Visual Studio Code has a decent debug console that can show your console.log.

    VS Code is, more often than not, React Native friendly.

    0 讨论(0)
  • 2020-11-30 17:21

    You can use remote js debugly option from your device or you can simply use react-native log-android and react-native log-ios for ios.

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