From 49d7c00500d8cd4b742e8aaa9c92e39f92c3b6e5 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Fri, 13 Jan 2017 12:26:26 -0800 Subject: [PATCH] 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 --- Libraries/ReactNative/YellowBox.js | 5 +++++ docs/Debugging.md | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/ReactNative/YellowBox.js b/Libraries/ReactNative/YellowBox.js index e3aee27b5..0a5e1b51c 100644 --- a/Libraries/ReactNative/YellowBox.js +++ b/Libraries/ReactNative/YellowBox.js @@ -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; + } } /** diff --git a/docs/Debugging.md b/docs/Debugging.md index 1888650b8..a011eb4ae 100644 --- a/docs/Debugging.md +++ b/docs/Debugging.md @@ -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.