diff --git a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm index 670c02299601ec..39377fe8b6f846 100644 --- a/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +++ b/packages/react-native/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm @@ -125,9 +125,6 @@ - (void)surface:(RCTSurface *)surface didChangeStage:(RCTSurfaceStage)stage [super surface:surface didChangeStage:stage]; if (RCTSurfaceStageIsRunning(stage)) { [_bridge.performanceLogger markStopForTag:RCTPLTTI]; - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification object:self]; - }); } } diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Root/RCTRootComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Root/RCTRootComponentView.mm index eb81a151c3fc41..c7d0a525a9ac74 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Root/RCTRootComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Root/RCTRootComponentView.mm @@ -7,18 +7,22 @@ #import "RCTRootComponentView.h" +#import #import #import #import "RCTConversions.h" using namespace facebook::react; -@implementation RCTRootComponentView +@implementation RCTRootComponentView { + BOOL _contentHasAppeared; +} - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { _props = RootShadowNode::defaultSharedProps(); + _contentHasAppeared = NO; } return self; @@ -26,6 +30,23 @@ - (instancetype)initWithFrame:(CGRect)frame #pragma mark - RCTComponentViewProtocol +- (void)prepareForRecycle +{ + [super prepareForRecycle]; + _contentHasAppeared = NO; +} + +- (void)mountChildComponentView:(UIView *)childComponentView index:(NSInteger)index +{ + [super mountChildComponentView:childComponentView index:index]; + if (!self->_contentHasAppeared) { + self->_contentHasAppeared = YES; + dispatch_async(dispatch_get_main_queue(), ^{ + [[NSNotificationCenter defaultCenter] postNotificationName:RCTContentDidAppearNotification object:self]; + }); + } +} + + (ComponentDescriptorProvider)componentDescriptorProvider { return concreteComponentDescriptorProvider();