mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
have RCTInstance decorate non-app provided turbomodules with bridgeless APIs (#48053)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48053 Changelog: [Internal] `getModuleInstanceFromClass:` is a delegate method intended to be implemented by the product layer to provide modules. if it is not implemented to return a module for a given key, `RCTTurboModuleManager` will simply call `new` on the TM class. however, these two paths differentiate - for `getModuleInstanceFromClass:`, we will call `_attachBridgelessAPIsToModule:` which provides objects like surfacePresenter to the native module. if we fallback to calling `new`, then this attachment does not happen, even if the app has already been migrated to bridgeless modules. thus, the fix in the case is to lift the fallback into RCTInstance as well, and decorate the APIs onto the new fallback. Reviewed By: cipolleschi Differential Revision: D66675034 fbshipit-source-id: 1ab89a4006d05f744f5d42b5de786ccea4d4a55d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
74f3ab7d40
commit
0217d7e19c
+7
-10
@@ -185,22 +185,19 @@ void RCTInstanceSetRuntimeDiagnosticFlags(NSString *flags)
|
||||
|
||||
- (Class)getModuleClassFromName:(const char *)name
|
||||
{
|
||||
if ([_appTMMDelegate respondsToSelector:@selector(getModuleClassFromName:)]) {
|
||||
return [_appTMMDelegate getModuleClassFromName:name];
|
||||
}
|
||||
|
||||
return nil;
|
||||
return [_appTMMDelegate getModuleClassFromName:name];
|
||||
}
|
||||
|
||||
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
||||
{
|
||||
if ([_appTMMDelegate respondsToSelector:@selector(getModuleInstanceFromClass:)]) {
|
||||
id<RCTTurboModule> module = [_appTMMDelegate getModuleInstanceFromClass:moduleClass];
|
||||
[self _attachBridgelessAPIsToModule:module];
|
||||
return module;
|
||||
id<RCTTurboModule> module = [_appTMMDelegate getModuleInstanceFromClass:moduleClass];
|
||||
|
||||
if (!module) {
|
||||
module = [moduleClass new];
|
||||
}
|
||||
|
||||
return nil;
|
||||
[self _attachBridgelessAPIsToModule:module];
|
||||
return module;
|
||||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
||||
|
||||
Reference in New Issue
Block a user