From 4636029acae3ae57e19897841cf7bd7dafe0da8a Mon Sep 17 00:00:00 2001 From: Ramanpreet Nara Date: Thu, 25 Jan 2024 16:56:49 -0800 Subject: [PATCH] Finish lazilyLoadView Summary: This API was used by the old architecture to lazily register/load components: 1. Load a ViewManager's class from the disk 2. Register the ViewManager's class with React Native See: [RCTUIManager lazilyLoadView](https://github.com/facebook/react-native/blob/822bf52c29729d25b2bfb31655cf773609a9283d/packages/react-native/React/Modules/RCTUIManager.m#L1546-L1591) The new architecture **does not** support lazy loading of **legacy** modules/components. Therefore, let's leave this API unimplemented until we decide to implement lazy loading of legacy stuff in new architecture. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D52677515 fbshipit-source-id: 8d49a0b54f901a3e9b3e8a9578ebb0c81de522d8 --- .../Libraries/ReactNative/BridgelessUIManager.js | 5 +++++ .../RCTLegacyViewManagerInteropComponentView.mm | 1 + .../React/Fabric/Mounting/RCTComponentViewFactory.mm | 1 + .../core/platform/ios/ReactCommon/RCTTurboModuleManager.mm | 1 + 4 files changed, 8 insertions(+) diff --git a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js index 73ef30c8e45645..61414d6c26cc4e 100644 --- a/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js +++ b/packages/react-native/Libraries/ReactNative/BridgelessUIManager.js @@ -245,6 +245,11 @@ const UIManagerJSPlatformAPIs = Platform.select({ }, }, ios: { + /** + * TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture. + * + * Leave this unimplemented until we implement lazy loading of legacy modules and view managers in the new architecture. + */ lazilyLoadView: (name: string): Object => { raiseSoftError('lazilyLoadView'); return {}; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm index 830d9aef0dd18c..b29cffd89bed13 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm @@ -130,6 +130,7 @@ + (BOOL)isSupported:(NSString *)componentName } // Step 3: check if the module has been registered + // TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture. NSArray *registeredModules = RCTGetModuleClasses(); NSMutableDictionary *supportedLegacyViewComponents = [RCTLegacyViewManagerInteropComponentView _supportedLegacyViewComponents]; diff --git a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm index ebd9d5a6e9e1d6..1f4d7488ba3dd4 100644 --- a/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm +++ b/packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm @@ -135,6 +135,7 @@ - (BOOL)registerComponentIfPossible:(const std::string &)name } // Fallback 3: Try to use Paper Interop. + // TODO(T174674274): Implement lazy loading of legacy view managers in the new architecture. if (RCTFabricInteropLayerEnabled() && [RCTLegacyViewManagerInteropComponentView isSupported:componentNameString]) { RCTLogNewArchitectureValidation( RCTNotAllowedInBridgeless, diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm index e01659a871fc26..997737d1a0c387 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm +++ b/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModuleManager.mm @@ -231,6 +231,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge } if (RCTTurboModuleInteropEnabled()) { + // TODO(T174674274): Implement lazy loading of legacy modules in the new architecture. NSMutableDictionary> *legacyInitializedModules = [NSMutableDictionary new]; if ([_delegate respondsToSelector:@selector(extraModulesForBridge:)]) {