Skip to content

Commit 2217ea4

Browse files
liamxujiafacebook-github-bot
authored andcommitted
Repair when RCTRedBoxGetEnabled is false , inoperative in RCTExceptio… (#35576)
Summary: Repair when RCTRedBoxGetEnabled is false , the red box will still be on display,It resolve that I send test-pack to QA with Xcode Archive on DEBUG env. ## Changelog [General] [Changed] - Append RCTRedBoxGetEnabled() in RCTExceptionsManager.mm Pull Request resolved: #35576 Test Plan: Xcode Archive on DEBUG env, the red box will be not on display. Reviewed By: cipolleschi Differential Revision: D41809649 Pulled By: skinsshark fbshipit-source-id: 7d6be3479decf369c415f6a08dec9611b1441b1d
1 parent 21dbc67 commit 2217ea4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

React/CoreModules/RCTExceptionsManager.mm

+13-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#import <React/RCTDefines.h>
1313
#import <React/RCTLog.h>
1414
#import <React/RCTRedBox.h>
15+
#import <React/RCTRedBoxSetEnabled.h>
1516
#import <React/RCTReloadCommand.h>
1617
#import <React/RCTRootView.h>
1718

@@ -40,8 +41,10 @@ - (void)reportSoft:(NSString *)message
4041
exceptionId:(double)exceptionId
4142
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
4243
{
43-
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
44-
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
44+
if (RCTRedBoxGetEnabled()) {
45+
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
46+
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
47+
}
4548

4649
if (_delegate) {
4750
[_delegate handleSoftJSExceptionWithMessage:message
@@ -56,8 +59,10 @@ - (void)reportFatal:(NSString *)message
5659
exceptionId:(double)exceptionId
5760
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
5861
{
59-
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
60-
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
62+
if (RCTRedBoxGetEnabled()) {
63+
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
64+
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
65+
}
6166

6267
if (_delegate) {
6368
[_delegate handleFatalJSExceptionWithMessage:message
@@ -99,8 +104,10 @@ - (void)reportFatal:(NSString *)message
99104
: (NSArray<NSDictionary *> *)stack exceptionId
100105
: (double)exceptionId)
101106
{
102-
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
103-
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
107+
if (RCTRedBoxGetEnabled()) {
108+
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
109+
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
110+
}
104111

105112
if (_delegate && [_delegate respondsToSelector:@selector(updateJSExceptionWithMessage:stack:exceptionId:)]) {
106113
[_delegate updateJSExceptionWithMessage:message stack:stack exceptionId:[NSNumber numberWithDouble:exceptionId]];

0 commit comments

Comments
 (0)