Skip to content

Commit 2b0e406

Browse files
cipolleschireact-native-bot
authored andcommitted
Fix TMManager moduleProviderForName (#49835)
Summary: Pull Request resolved: #49835 The implementation of moduleProviderForName is slightly off. This method was supposed to replace the previous ternary expression and to enhance with the module provider call. The ternary expression used to be ``` !RCTTurboModuleInteropEnabled() || [self _isTurboModule:moduleName] ? [self _provideObjCModule:moduleName] : nil ``` However, as you can see from the current implementation, instead of calling `RCTTurboModuleInteropEnabled()` we are calling `RCTTurboModuleEnabled()` which is clearly a mistake. On top of that, I'm also updating the guard around the `getModuleProvider` selector as it was bypassing the other checks, and that's wrong. ## Changelog: [Internal] - Fix moduleProviderForName method Reviewed By: RSNara Differential Revision: D70569552 fbshipit-source-id: ed4055da9ea385ed10323ed8d7a8772010b3a105
1 parent eb02343 commit 2b0e406

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,21 +493,22 @@ - (BOOL)_isLegacyModuleClass:(Class)moduleClass
493493

494494
- (id<RCTModuleProvider>)_moduleProviderForName:(const char *)moduleName
495495
{
496+
id<RCTModuleProvider> moduleProvider = nil;
496497
if ([_delegate respondsToSelector:@selector(getModuleProvider:)]) {
497-
id<RCTModuleProvider> moduleProvider = [_delegate getModuleProvider:moduleName];
498-
BOOL isTurboModule = [self _isTurboModule:moduleName];
499-
if (RCTTurboModuleEnabled() && !isTurboModule && !moduleProvider) {
500-
return nil;
501-
}
498+
moduleProvider = [_delegate getModuleProvider:moduleName];
499+
}
502500

503-
if (moduleProvider) {
504-
if ([moduleProvider conformsToProtocol:@protocol(RCTTurboModule)]) {
505-
// moduleProvider is also a TM, we need to initialize objectiveC properties, like the dispatch queue
506-
return (id<RCTModuleProvider>)[self _provideObjCModule:moduleName moduleProvider:moduleProvider];
507-
}
508-
// module is Cxx module
509-
return moduleProvider;
501+
if (RCTTurboModuleInteropEnabled() && ![self _isTurboModule:moduleName] && !moduleProvider) {
502+
return nil;
503+
}
504+
505+
if (moduleProvider) {
506+
if ([moduleProvider conformsToProtocol:@protocol(RCTTurboModule)]) {
507+
// moduleProvider is also a TM, we need to initialize objectiveC properties, like the dispatch queue
508+
return (id<RCTModuleProvider>)[self _provideObjCModule:moduleName moduleProvider:moduleProvider];
510509
}
510+
// module is Cxx module
511+
return moduleProvider;
511512
}
512513

513514
// No module provider, the Module is registered without Codegen

0 commit comments

Comments
 (0)