Skip to content

Commit

Permalink
Repair when RCTRedBoxGetEnabled is false , inoperative in RCTExceptio… (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
liamxujia authored and facebook-github-bot committed Jan 4, 2023
1 parent 21dbc67 commit 2217ea4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions React/CoreModules/RCTExceptionsManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#import <React/RCTDefines.h>
#import <React/RCTLog.h>
#import <React/RCTRedBox.h>
#import <React/RCTRedBoxSetEnabled.h>
#import <React/RCTReloadCommand.h>
#import <React/RCTRootView.h>

Expand Down Expand Up @@ -40,8 +41,10 @@ - (void)reportSoft:(NSString *)message
exceptionId:(double)exceptionId
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

if (_delegate) {
[_delegate handleSoftJSExceptionWithMessage:message
Expand All @@ -56,8 +59,10 @@ - (void)reportFatal:(NSString *)message
exceptionId:(double)exceptionId
extraDataAsJSON:(nullable NSString *)extraDataAsJSON
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

if (_delegate) {
[_delegate handleFatalJSExceptionWithMessage:message
Expand Down Expand Up @@ -99,8 +104,10 @@ - (void)reportFatal:(NSString *)message
: (NSArray<NSDictionary *> *)stack exceptionId
: (double)exceptionId)
{
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
if (RCTRedBoxGetEnabled()) {
RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"];
[redbox updateErrorMessage:message withStack:stack errorCookie:(int)exceptionId];
}

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

0 comments on commit 2217ea4

Please sign in to comment.