Skip to content

Commit 4266781

Browse files
zhongwuzwpull[bot]
authored andcommitted
RNTester enable concurrent root when using Fabric (facebook#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. ![image](https://github.com/facebook/react-native/assets/5061845/12af5815-afe6-46f0-8107-54ca443b4962) cc javache cipolleschi ## Changelog: [IOS] [FIXED] - RNTester enable concurrent root when using Fabric Pull Request resolved: facebook#41166 Test Plan: Warning disappear. Reviewed By: cipolleschi Differential Revision: D50596693 Pulled By: javache fbshipit-source-id: d73a17cd137b3088405f86b739cb0ed7b5a9839e
1 parent 83dd571 commit 4266781

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@
101101
* By default, it assigns the rootView to the view property of the rootViewController
102102
* If you are not using a simple UIViewController, then there could be other methods to use to setup the rootView.
103103
* For example: UISplitViewController requires `setViewController(_:for:)`
104-
*
105-
* @return: void
106104
*/
107105
- (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
108106

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,19 @@ @interface RCTAppDelegate () <
5353

5454
#endif
5555

56+
static NSDictionary *updateInitialProps(NSDictionary *initialProps, BOOL isFabricEnabled)
57+
{
58+
#ifdef RCT_NEW_ARCH_ENABLED
59+
NSMutableDictionary *mutableProps = [initialProps mutableCopy] ?: [NSMutableDictionary new];
60+
// Hardcoding the Concurrent Root as it it not recommended to
61+
// have the concurrentRoot turned off when Fabric is enabled.
62+
mutableProps[kRNConcurrentRoot] = @(isFabricEnabled);
63+
return mutableProps;
64+
#else
65+
return initialProps;
66+
#endif
67+
}
68+
5669
@interface RCTAppDelegate () <RCTCxxBridgeDelegate> {
5770
std::shared_ptr<facebook::react::RuntimeScheduler> _runtimeScheduler;
5871
}
@@ -80,18 +93,21 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
8093
{
8194
BOOL enableTM = NO;
8295
BOOL enableBridgeless = NO;
96+
BOOL fabricEnabled = NO;
8397
#if RCT_NEW_ARCH_ENABLED
8498
enableTM = self.turboModuleEnabled;
8599
enableBridgeless = self.bridgelessEnabled;
100+
fabricEnabled = [self fabricEnabled];
86101
#endif
102+
NSDictionary *initProps = updateInitialProps([self prepareInitialProps], fabricEnabled);
87103

88104
RCTAppSetupPrepareApp(application, enableTM);
89105

90106
UIView *rootView;
91107
if (enableBridgeless) {
92108
#if RCT_NEW_ARCH_ENABLED
93109
// Enable native view config interop only if both bridgeless mode and Fabric is enabled.
94-
RCTSetUseNativeViewConfigsInBridgelessMode([self fabricEnabled]);
110+
RCTSetUseNativeViewConfigsInBridgelessMode(fabricEnabled);
95111

96112
// Enable TurboModule interop by default in Bridgeless mode
97113
RCTEnableTurboModuleInterop(YES);
@@ -100,7 +116,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
100116
[self createReactHost];
101117
[self unstable_registerLegacyComponents];
102118
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
103-
NSDictionary *initProps = [self prepareInitialProps];
104119
RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:self.moduleName initialProperties:initProps];
105120

106121
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
@@ -121,7 +136,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
121136
[self unstable_registerLegacyComponents];
122137
[RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = self;
123138
#endif
124-
NSDictionary *initProps = [self prepareInitialProps];
139+
125140
rootView = [self createRootViewWithBridge:self.bridge moduleName:self.moduleName initProps:initProps];
126141
}
127142
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
@@ -143,15 +158,7 @@ - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
143158

144159
- (NSDictionary *)prepareInitialProps
145160
{
146-
NSMutableDictionary *initProps = self.initialProps ? [self.initialProps mutableCopy] : [NSMutableDictionary new];
147-
148-
#ifdef RCT_NEW_ARCH_ENABLED
149-
// Hardcoding the Concurrent Root as it it not recommended to
150-
// have the concurrentRoot turned off when Fabric is enabled.
151-
initProps[kRNConcurrentRoot] = @([self fabricEnabled]);
152-
#endif
153-
154-
return initProps;
161+
return self.initialProps;
155162
}
156163

157164
- (RCTBridge *)createBridgeWithDelegate:(id<RCTBridgeDelegate>)delegate launchOptions:(NSDictionary *)launchOptions

0 commit comments

Comments
 (0)