Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing console.log from React Native app

Should you remove the console.log() calls before deploying a React Native app to the stores? Are there some performance or other issues that exist if the console.log() calls are kept in the code?

Is there a way to remove the logs with some task runner (in a similar fashion to web-related task runners like Grunt or Gulp)? We still want them during our development/debugging/testing phase but not on production.

like image 897
RRikesh Avatar asked Aug 14 '16 06:08

RRikesh


People also ask

How do I get rid of console log in react native?

Luckily, there's a simple way to remove console. log from production with little effort. The babel-plugin-transform-remove-console babel plugin helps you to remove all console.

Can you delete console log?

Use the short cut Ctrl + L to clear the console. Use the clear log button on the top left corner of the chrome dev tools console to clear the console.

Does console log slow down react native?

yes. More code means a longer execution time. Not only will it take unnecessary CPU "power", console. log is also synchronous so it will make your application slower (even by a few nanoseconds).


1 Answers

Well, you can always do something like:

if (!__DEV__) {   console.log = () => {}; } 

So every console.log would be invalidated as soon as __DEV__ is not true.

like image 98
Lucas Bento Avatar answered Sep 19 '22 15:09

Lucas Bento