Podgeypoos
Podgeypoos

Reputation: 177

React Native turn off Debug mode and stop displaying warning messages

I currently have a scenario where warning messages are turning up on my production app, It is not clear how to turn off these warnings. Anyone know what the Android equivalent is to

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=false"];

Upvotes: 1

Views: 11637

Answers (2)

Podgeypoos
Podgeypoos

Reputation: 177

in index.android.bundle file in the assets folder there is an entry

(function(global) {global.
    __DEV__=true;

set to false and all my issues went away

Upvotes: 1

Daniel Schmidt
Daniel Schmidt

Reputation: 11921

First of all, normally you should bundle your JS if you plan to run the app in production mode, e.g. by running some command like this:

node node_modules/react-native/local-cli/cli.js bundle --dev false --platform ios --entry-file ./index.ios.js --bundle-output ./ios/main.jsbundle

To answer your question, the android/src/main/java/com/YOUR_PROJECT_NAME/MainActivity.java file should contain something like this

/**
  * Returns whether dev mode should be enabled.
  * This enables e.g. the dev menu.
  */
  @Override
  protected boolean getUseDeveloperSupport() {
    return BuildConfig.DEBUG;
  }

Which you may change to

/**
  * Returns whether dev mode should be enabled.
  * This enables e.g. the dev menu.
  */
  @Override
  protected boolean getUseDeveloperSupport() {
    return false;
  }

Edit: fixed typo

Upvotes: 3

Related Questions