How to do logging in React Native?

前端 未结 30 3545
不思量自难忘°
不思量自难忘° 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:29

    There are several ways to achieve this, I am listing them and including cons in using them also. You can use:

    1. console.log and view logging statements on, without opting out for remote debugging option from dev tools, Android Studio and Xcode. or you can opt out for remote debugging option and view logging on chrome dev tools or vscode or any other editor that supports debugging, you have to be cautious as this will slow down the process as a whole.
    2. You can use console.warn but then your mobile screen would be flooded with those weird yellow boxes which might or might not be feasible according to your situation.
    3. Most effective method that I came across is to use a third party tool, Reactotron. A simple and easy to configure tool that enables you to see each logging statement of different levels (error, debug, warn, etc.). It provides you with the GUI tool that shows all the logging of your app without slowing down the performance.

提交回复
热议问题