mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix TMManager moduleProviderForName (#49835)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/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
This commit is contained in:
committed by
React Native Bot
parent
eb02343f95
commit
2b0e406fef
+13
-12
@@ -493,21 +493,22 @@ typedef struct {
|
||||
|
||||
- (id<RCTModuleProvider>)_moduleProviderForName:(const char *)moduleName
|
||||
{
|
||||
id<RCTModuleProvider> moduleProvider = nil;
|
||||
if ([_delegate respondsToSelector:@selector(getModuleProvider:)]) {
|
||||
id<RCTModuleProvider> moduleProvider = [_delegate getModuleProvider:moduleName];
|
||||
BOOL isTurboModule = [self _isTurboModule:moduleName];
|
||||
if (RCTTurboModuleEnabled() && !isTurboModule && !moduleProvider) {
|
||||
return nil;
|
||||
}
|
||||
moduleProvider = [_delegate getModuleProvider:moduleName];
|
||||
}
|
||||
|
||||
if (moduleProvider) {
|
||||
if ([moduleProvider conformsToProtocol:@protocol(RCTTurboModule)]) {
|
||||
// moduleProvider is also a TM, we need to initialize objectiveC properties, like the dispatch queue
|
||||
return (id<RCTModuleProvider>)[self _provideObjCModule:moduleName moduleProvider:moduleProvider];
|
||||
}
|
||||
// module is Cxx module
|
||||
return moduleProvider;
|
||||
if (RCTTurboModuleInteropEnabled() && ![self _isTurboModule:moduleName] && !moduleProvider) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (moduleProvider) {
|
||||
if ([moduleProvider conformsToProtocol:@protocol(RCTTurboModule)]) {
|
||||
// moduleProvider is also a TM, we need to initialize objectiveC properties, like the dispatch queue
|
||||
return (id<RCTModuleProvider>)[self _provideObjCModule:moduleName moduleProvider:moduleProvider];
|
||||
}
|
||||
// module is Cxx module
|
||||
return moduleProvider;
|
||||
}
|
||||
|
||||
// No module provider, the Module is registered without Codegen
|
||||
|
||||
Reference in New Issue
Block a user