Removing console.log from React Native app

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.

Babel transpiler can remove console statements for you with the following plugin:

npm i babel-plugin-transform-remove-console --save-dev

Edit .babelrc:

  "env": {
    "production": {
      "plugins": ["transform-remove-console"]

And console statements are stripped out of your code.


believe best practice is to wrap your debug code in statements such as...


This way, it only runs when you're running within the packager or emulator. More info here...