From e97baa6066f229ef05e2a5f518e606e29edbdab7 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Tue, 10 Dec 2019 21:47:42 -0800 Subject: [PATCH] LogBox iOS: don't initialize logbox window if redbox flag is disabled Summary: If redbox flag is disabled, don't initialize LogBox window even if the native module exists. This makes the module noop. Changelog: [Internal] Reviewed By: shergin Differential Revision: D18927309 fbshipit-source-id: 3dc6c08ed537925594cabf77d1142568d47132e9 --- React/CoreModules/RCTLogBox.mm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/React/CoreModules/RCTLogBox.mm b/React/CoreModules/RCTLogBox.mm index cda46ca31f7..0041ed28352 100644 --- a/React/CoreModules/RCTLogBox.mm +++ b/React/CoreModules/RCTLogBox.mm @@ -15,6 +15,7 @@ #import #import #import +#import #import #import @@ -102,10 +103,13 @@ RCT_EXPORT_MODULE() - (void)setBridge:(RCTBridge *)bridge { - _bridge = bridge; - dispatch_async(dispatch_get_main_queue(), ^{ - self->_window = [[RCTLogBoxWindow alloc] initWithFrame:[UIScreen mainScreen].bounds bridge: self->_bridge]; - }); + _bridge = bridge; + + if (RCTRedBoxGetEnabled()) { + dispatch_async(dispatch_get_main_queue(), ^{ + self->_window = [[RCTLogBoxWindow alloc] initWithFrame:[UIScreen mainScreen].bounds bridge: self->_bridge]; + }); + } } RCT_EXPORT_METHOD(show)