Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export Commands and Constants only if native view config interop is enabled #39696

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/react-native/React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -1489,9 +1489,10 @@ static void RCTMeasureLayout(RCTShadowView *view, RCTShadowView *ancestor, RCTRe
// lazifyViewManagerConfig function in JS. This fuction uses NativeModules global object that is not available in the
// New Architecture. To make native view configs work in the New Architecture we will populate these properties in
// native.
moduleConstants[@"Commands"] = viewConfig[@"Commands"];
moduleConstants[@"Constants"] = viewConfig[@"Constants"];

if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
moduleConstants[@"Commands"] = viewConfig[@"Commands"];
moduleConstants[@"Constants"] = viewConfig[@"Constants"];
}
// Add direct events
for (NSString *eventName in viewConfig[@"directEvents"]) {
if (!directEvents[eventName]) {
Expand Down
20 changes: 11 additions & 9 deletions packages/react-native/React/Views/RCTComponentData.m
Original file line number Diff line number Diff line change
Expand Up @@ -480,11 +480,6 @@ - (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowV
}
}

NSDictionary<NSString *, NSNumber *> *commands = [self commandsForViewMangerClass:managerClass
methods:methods
methodCount:count];
free(methods);

#if RCT_DEBUG
for (NSString *event in bubblingEvents) {
if ([directEvents containsObject:event]) {
Expand All @@ -499,15 +494,22 @@ - (void)setProps:(NSDictionary<NSString *, id> *)props forShadowView:(RCTShadowV

Class superClass = [managerClass superclass];

return @{
NSMutableDictionary *result = [[NSMutableDictionary alloc] initWithDictionary:@{
@"propTypes" : propTypes,
@"directEvents" : directEvents,
@"bubblingEvents" : bubblingEvents,
@"capturingEvents" : capturingEvents,
@"baseModuleName" : superClass == [NSObject class] ? (id)kCFNull : RCTViewManagerModuleNameForClass(superClass),
@"Commands" : commands,
@"Constants" : [self constantsForViewMangerClass:managerClass],
};
}];

if (RCTGetUseNativeViewConfigsInBridgelessMode()) {
result[@"Commands"] = [self commandsForViewMangerClass:managerClass methods:methods methodCount:count];
result[@"Constants"] = [self constantsForViewMangerClass:managerClass];
}

free(methods);

return result;
}

- (NSDictionary<NSString *, id> *)viewConfig
Expand Down