Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,15 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc

#pragma mark - RCTRootViewFactory Helpers

/**
* Initialize React Host/Bridge without creating a view.
*
* Use it to speed up later viewWithModuleName: calls.
*
* @parameter: launchOptions - a dictionary with a set of options.
*/
- (void)initializeReactHostWithLaunchOptions:(NSDictionary *__nullable)launchOptions;

- (RCTHost *)createReactHost:(NSDictionary *__nullable)launchOptions;

@end
Expand Down
20 changes: 14 additions & 6 deletions packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,28 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
return [self viewWithModuleName:moduleName initialProperties:nil launchOptions:nil];
}

- (UIView *)viewWithModuleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initProps
launchOptions:(NSDictionary *)launchOptions
- (void)initializeReactHostWithLaunchOptions:(NSDictionary *)launchOptions
{
if (_configuration.bridgelessEnabled) {
// Enable TurboModule interop by default in Bridgeless mode
RCTEnableTurboModuleInterop(YES);
RCTEnableTurboModuleInteropBridgeProxy(YES);

[self createReactHostIfNeeded:launchOptions];
return;
}

[self createBridgeIfNeeded:launchOptions];
[self createBridgeAdapterIfNeeded];
}

- (UIView *)viewWithModuleName:(NSString *)moduleName
initialProperties:(NSDictionary *)initProps
launchOptions:(NSDictionary *)launchOptions
{
[self initializeReactHostWithLaunchOptions:launchOptions];

if (_configuration.bridgelessEnabled) {
RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];

RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
Expand All @@ -155,9 +166,6 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
return surfaceHostingProxyRootView;
}

[self createBridgeIfNeeded:launchOptions];
[self createBridgeAdapterIfNeeded];

UIView *rootView;
if (_configuration.createRootViewWithBridge != nil) {
rootView = _configuration.createRootViewWithBridge(self.bridge, moduleName, initProps);
Expand Down