mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Allow the TurboModule system to create legacy modules (#37395)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/37395 Pull Request resolved: https://github.com/facebook/react-native/pull/37364 When the TurboModule interop layer is enabled, it should create modules that conform to RCTBridgeModule (i.e: legacy and turbo modules). When the TurboModule interop layer is disabled, it should only create modules that conform to RCTTurboModule (i.e: turbo modules). Changelog: [Internal] Reviewed By: cipolleschi Differential Revision: D45781155 fbshipit-source-id: 2bf2c6cdbe0db99a57fce0d0c21c66aee3465e0d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
853695ebd2
commit
5ce042f0b2
+10
-1
@@ -420,7 +420,7 @@ static Class getFallbackClassFromName(const char *name)
|
||||
|
||||
__block id<RCTBridgeModule> module = nil;
|
||||
|
||||
if ([moduleClass conformsToProtocol:@protocol(RCTTurboModule)]) {
|
||||
if ([self _shouldCreateObjCModule:moduleClass]) {
|
||||
__weak __typeof(self) weakSelf = self;
|
||||
dispatch_block_t work = ^{
|
||||
auto strongSelf = weakSelf;
|
||||
@@ -478,6 +478,15 @@ static Class getFallbackClassFromName(const char *name)
|
||||
return moduleHolder->getModule();
|
||||
}
|
||||
|
||||
- (BOOL)_shouldCreateObjCModule:(Class)moduleClass
|
||||
{
|
||||
if (RCTTurboModuleInteropEnabled()) {
|
||||
return [moduleClass conformsToProtocol:@protocol(RCTBridgeModule)];
|
||||
}
|
||||
|
||||
return [moduleClass conformsToProtocol:@protocol(RCTTurboModule)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a NativeModule class, and its name, create and initialize it synchronously.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user