Skip to content

Commit

Permalink
Remove implicit "start", then clean up callsites (#47313)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Nolan O'Brien authored and facebook-github-bot committed Oct 31, 2024
1 parent 3a01a0c commit 13b93cf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ void RCTAppSetupPrepareApp(UIApplication *application, BOOL turboModuleEnabled)
id<RCTSurfaceProtocol> surface = [[RCTFabricSurface alloc] initWithBridge:bridge
moduleName:moduleName
initialProperties:initialProperties];
return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
[surface start];
return rootView;
}
return [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,8 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName

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

RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView =
[[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];

surfaceHostingProxyRootView.backgroundColor = [UIColor systemBackgroundColor];
if (self->_configuration.customizeRootView != nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ @implementation RCTSurfaceHostingProxyRootView

- (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
{
if (self = [super initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact]) {
[surface start];
}
return self;
return [super initWithSurface:surface
sizeMeasureMode:RCTSurfaceSizeMeasureModeWidthExact | RCTSurfaceSizeMeasureModeHeightExact];
}

RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
Expand Down

0 comments on commit 13b93cf

Please sign in to comment.