Skip to content

Commit 13b93cf

Browse files
Nolan O'Brienfacebook-github-bot
Nolan O'Brien
authored andcommitted
Remove implicit "start", then clean up callsites (#47313)
Summary: Pull Request resolved: #47313 We're going to fix up a bunch of designated initializers. `RCTSurfaceHostingProxyRootView` is particularly problematic because different initializers will do different things even though reading the code it looks like they should be equivalent. Remove the encapsulated "start" to the provided "surface", and require it to be explicit at the callsite. ## Changelog: [iOS][Changed] - `RCTSurfaceHostingProxyRootView` no longer has different behavior (whether it calls `start` on the provided *surface*) depending on which initializer is used. Call `start` yourself on the *surface* instead. Reviewed By: cipolleschi Differential Revision: D65214656 fbshipit-source-id: 179d5220d4f866b4452561e1bb6e2051020c8a11
1 parent 3a01a0c commit 13b93cf

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
5353
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
5454
moduleName:moduleName
5555
initialProperties:initialProperties];
56-
return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
56+
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
57+
[surface start];
58+
return rootView;
5759
}
5860
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
5961
}

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,8 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName
172172

173173
RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];
174174

175-
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
176-
initWithSurface:surface
177-
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
175+
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
176+
[[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
178177

179178
surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
180179
if (self->_configuration.customizeRootView != nil) {

packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm

+2-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ @implementation RCTSurfaceHostingProxyRootView
5353

5454
- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
5555
{
56-
if (self = [super initWithSurface:surface
57-
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact]) {
58-
[surface start];
59-
}
60-
return self;
56+
return [super initWithSurface:surface
57+
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
6158
}
6259

6360
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)

0 commit comments

Comments
 (0)