How to do logging in React Native?

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

    Development Time Logging

    For development time logging, you can use console.log(). One important thing, if you want to disable logging in production mode, then in Root Js file of app, just assign blank function like this - console.log = {} It will disable whole log publishing throughout app altogether, which actually required in production mode as console.log consumes time.


    Run Time Logging

    In production mode, it is also required to see logs when real users are using your app in real time. This helps in understanding bugs, usage and unwanted cases. There are many 3rd party paid tools available in the market for this. One of them which I've used is by Logentries

    The good thing is that Logentries has got React Native Module as well. So, it will take very less time for you to enable Run time logging with your mobile app.

提交回复
热议问题