Skip to content

Commit

Permalink
(Easy) Log errors to Logview when Bridge is used in Bridgeless
Browse files Browse the repository at this point in the history
Summary:
Changelog: [Internal]

# Diff Changes
- Set `RCTEnableNewArchitectureViolationReporting` to YES in app-wide Bridgeless mode.
- Rename `RCTWarnNotAllowedForNewArchitecture` to `RCTErrorNotAllowedForNewArchitecture`, and use `RCTLogError` instead of `RCTLogWarn` so the error goes to Logview.

Reviewed By: RSNara

Differential Revision: D34202682

fbshipit-source-id: 471486c65f7a42f8f11140e61ff60592dc826f61
  • Loading branch information
p-sun authored and facebook-github-bot committed Feb 15, 2022
1 parent 74f5697 commit 3c4850d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions React/Base/RCTAssert.h
Expand Up @@ -183,7 +183,6 @@ __attribute__((used)) RCT_EXTERN void RCTEnableNewArchitectureViolationReporting

// When reporting is enabled, trigger an assertion.
__attribute__((used)) RCT_EXTERN void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra);

// When reporting is enabled, warn about the violation. Use this to prepare a specific callsite
// When reporting is enabled, trigger an error but do not crash. Use this to prepare a specific callsite
// for stricter enforcement. When ready, switch it to use the variant above.
__attribute__((used)) RCT_EXTERN void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra);
__attribute__((used)) RCT_EXTERN void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra);
4 changes: 2 additions & 2 deletions React/Base/RCTAssert.m
Expand Up @@ -274,11 +274,11 @@ void RCTEnforceNotAllowedForNewArchitecture(id context, NSString *extra)
RCTAssert(0, @"%@", getNewArchitectureViolationMessage(context, extra));
}

void RCTWarnNotAllowedForNewArchitecture(id context, NSString *extra)
void RCTErrorNotAllowedForNewArchitecture(id context, NSString *extra)
{
if (!newArchitectureViolationReporting) {
return;
}

RCTLogWarn(@"%@", getNewArchitectureViolationMessage(context, extra));
RCTLogError(@"%@", getNewArchitectureViolationMessage(context, extra));
}
2 changes: 1 addition & 1 deletion React/Base/RCTBridge.m
Expand Up @@ -59,7 +59,7 @@
void RCTRegisterModule(Class);
void RCTRegisterModule(Class moduleClass)
{
RCTWarnNotAllowedForNewArchitecture(
RCTErrorNotAllowedForNewArchitecture(
@"RCTRegisterModule()", [NSString stringWithFormat:@"'%@' was registered unexpectedly", moduleClass]);

static dispatch_once_t onceToken;
Expand Down
Expand Up @@ -29,7 +29,7 @@ @implementation RCTLegacyViewManagerInteropComponentView {
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
RCTWarnNotAllowedForNewArchitecture(
RCTErrorNotAllowedForNewArchitecture(
self, @"ViewManager with interop layer is not allowed in the new architecture.");
static const auto defaultProps = std::make_shared<const LegacyViewManagerInteropViewProps>();
_props = defaultProps;
Expand Down
2 changes: 1 addition & 1 deletion React/Views/RCTViewManager.m
Expand Up @@ -82,7 +82,7 @@ - (dispatch_queue_t)methodQueue

- (void)setBridge:(RCTBridge *)bridge
{
RCTWarnNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
RCTErrorNotAllowedForNewArchitecture(self, @"RCTViewManager must not be initialized for the new architecture");
_bridge = bridge;
}

Expand Down

0 comments on commit 3c4850d

Please sign in to comment.