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 (#37364)
Summary: 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: mdvacca Differential Revision: D45706884 fbshipit-source-id: be6f054556d1506e2934884ab5014394f0c08e8f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
16a250eb13
commit
f8929f8d54
+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