mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
RNTester enable concurrent root when using Fabric (#41166)
Summary: RNTester's `AppDelegate` override `prepareInitialProps` method of super class `RCTAppDelegate` https://github.com/facebook/react-native/blob/70acd3f7d9edae9e40cc4603bede9778da281a85/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm#L152, so we missed `concurrentRoot` initial prop.  cc javache cipolleschi ## Changelog: [IOS] [FIXED] - RNTester enable concurrent root when using Fabric Pull Request resolved: https://github.com/facebook/react-native/pull/41166 Test Plan: Warning disappear. Reviewed By: cipolleschi Differential Revision: D50596693 Pulled By: javache fbshipit-source-id: d73a17cd137b3088405f86b739cb0ed7b5a9839e
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e167ac9eab
commit
b1e92d6e0d
@@ -101,8 +101,6 @@
|
||||
* By default, it assigns the rootView to the view property of the rootViewController
|
||||
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
|
||||
* For example: UISplitViewController requires `setViewController(_:for:)`
|
||||
*
|
||||
* @return: void
|
||||
*/
|
||||
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
|
||||
|
||||
|
||||
@@ -53,6 +53,19 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
|
||||
#endif
|
||||
|
||||
static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabricEnabled)
|
||||
{
|
||||
#ifdef RCT_NEW_ARCH_ENABLED
|
||||
NSMutableDictionary *mutableProps = [initialProps mutableCopy] ?: [NSMutableDictionary new];
|
||||
// Hardcoding the Concurrent Root as it it not recommended to
|
||||
// have the concurrentRoot turned off when Fabric is enabled.
|
||||
mutableProps[kRNConcurrentRoot] = @(isFabricEnabled);
|
||||
return mutableProps;
|
||||
#else
|
||||
return initialProps;
|
||||
#endif
|
||||
}
|
||||
|
||||
@interface RCTAppDelegate () <RCTCxxBridgeDelegate> {
|
||||
std::shared_ptr<facebook::react::RuntimeScheduler> _runtimeScheduler;
|
||||
}
|
||||
@@ -80,10 +93,13 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
{
|
||||
BOOL enableTM = NO;
|
||||
BOOL enableBridgeless = NO;
|
||||
BOOL fabricEnabled = NO;
|
||||
#if RCT_NEW_ARCH_ENABLED
|
||||
enableTM = self.turboModuleEnabled;
|
||||
enableBridgeless = self.bridgelessEnabled;
|
||||
fabricEnabled = [self fabricEnabled];
|
||||
#endif
|
||||
NSDictionary *initProps = updateInitialProps([self prepareInitialProps], fabricEnabled);
|
||||
|
||||
RCTAppSetupPrepareApp(application, enableTM);
|
||||
|
||||
@@ -91,7 +107,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
if (enableBridgeless) {
|
||||
#if RCT_NEW_ARCH_ENABLED
|
||||
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
|
||||
RCTSetUseNativeViewConfigsInBridgelessMode([self fabricEnabled]);
|
||||
RCTSetUseNativeViewConfigsInBridgelessMode(fabricEnabled);
|
||||
|
||||
// Enable TurboModule interop by default in Bridgeless mode
|
||||
RCTEnableTurboModuleInterop(YES);
|
||||
@@ -100,7 +116,6 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
[self createReactHost];
|
||||
[self unstable_registerLegacyComponents];
|
||||
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
|
||||
NSDictionary *initProps = [self prepareInitialProps];
|
||||
RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:self.moduleName initialProperties:initProps];
|
||||
|
||||
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
|
||||
@@ -121,7 +136,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
[self unstable_registerLegacyComponents];
|
||||
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
|
||||
#endif
|
||||
NSDictionary *initProps = [self prepareInitialProps];
|
||||
|
||||
rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps];
|
||||
}
|
||||
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
@@ -143,15 +158,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
|
||||
|
||||
- (NSDictionary *)prepareInitialProps
|
||||
{
|
||||
NSMutableDictionary *initProps = self.initialProps ? [self.initialProps mutableCopy] : [NSMutableDictionary new];
|
||||
|
||||
#ifdef RCT_NEW_ARCH_ENABLED
|
||||
// Hardcoding the Concurrent Root as it it not recommended to
|
||||
// have the concurrentRoot turned off when Fabric is enabled.
|
||||
initProps[kRNConcurrentRoot] = @([self fabricEnabled]);
|
||||
#endif
|
||||
|
||||
return initProps;
|
||||
return self.initialProps;
|
||||
}
|
||||
|
||||
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions
|
||||
|
||||
Reference in New Issue
Block a user