score:1

Accepted answer

since you are using react, my guess is you are already using babel. there's a plugin for that purpose. it's called babel-plugin-transform-remove-console. this will exclude all console.log's statement during the build process.
install that in your app and configure it via .babelrc as follows:

{
  "plugins": ["transform-remove-console"]
}

you can also specify the variant(s) of the console functions to exclude:

{
  "plugins": [ ["transform-remove-console", { "exclude": [ "error", "warn"] }] ]
}

my advise is to not use console logs in your code except necessary.

score:0

in my app.js i have the following code for accomplishing this:

import { yellowbox } from 'react-native';

componentdidmount() {
    // the following lines are a workaround
    // in order to stop getting warnings about timer
    // see: https://github.com/firebase/firebase-js-sdk/issues/97#issuecomment-365456531
    yellowbox.ignorewarnings(['setting a timer']);
    const _console = _.clone(console);
    console.warn = message => {
      if (message.indexof('setting a timer') <= -1) {
        _console.warn(message);
      }
    };
}

Related Query

More Query from same tag