Disable yellow box warnings based on environment variable

Summary:
This adds a hook to let you disable yellow box warnings. It's useful for native engineers who don't want to mess with JS but also for CI/testing, where the app operates mostly as a blackbox.

Depends on D4395091

Reviewed By: achen1

Differential Revision: D4395552

fbshipit-source-id: 4c3a9676caa975c537d1a4711d60aab2f404db15
This commit is contained in:
Mehdi Mulani 2017-01-13 12:26:26 -08:00 committed by Facebook Github Bot
parent 91b7499cf6
commit 49d7c00500
2 changed files with 8 additions and 1 deletions

View File

@ -69,6 +69,11 @@ if (__DEV__) {
warn.apply(console, arguments);
updateWarningMap.apply(null, arguments);
};
const ProcessInfo = require('NativeModules').ProcessInfo;
if (ProcessInfo && ProcessInfo.environment.DISABLE_YELLOW_BOX) {
(console: any).disableYellowBox = true;
}
}
/**

View File

@ -49,7 +49,9 @@ Warnings will be displayed on screen with a yellow background. These alerts are
As with a RedBox, you can use `console.warn()` to trigger a YellowBox.
YellowBoxes can be disabled during development by using `console.disableYellowBox = true;`. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: `console.ignoredYellowBox = ['Warning: ...'];`
YellowBoxes can be disabled during development by using `console.disableYellowBox = true;`. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: `console.ignoredYellowBox = ['Warning: ...'];`.
In CI/Xcode, YellowBoxes can also be disabled by setting the `DISABLE_YELLOW_BOX` environment variable.
> RedBoxes and YellowBoxes are automatically disabled in release (production) builds.