From f37ffd3156c084d1383cb0d5785bb25e5f134f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20B=C5=82oniarz?= Date: Wed, 15 Oct 2025 15:22:48 +0200 Subject: [PATCH 1/3] add snapshotAfterUpdates --- ios/RNSScreen.h | 3 ++- ios/RNSScreen.mm | 4 ++-- ios/RNSScreenStack.mm | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ios/RNSScreen.h b/ios/RNSScreen.h index 6b0c87abb7..c0bbf0d08a 100644 --- a/ios/RNSScreen.h +++ b/ios/RNSScreen.h @@ -53,7 +53,7 @@ namespace react = facebook::react; - (void)notifyFinishTransitioning; - (RNSScreenView *)screenView; #ifdef RCT_NEW_ARCH_ENABLED -- (void)setViewToSnapshot; +- (void)setViewToSnapshotAfterUpdates:(BOOL)afterUpdates; - (CGFloat)calculateHeaderHeightIsModal:(BOOL)isModal; #endif @@ -130,6 +130,7 @@ namespace react = facebook::react; @property (nonatomic, readonly) BOOL hasHeaderConfig; @property (nonatomic, readonly, getter=isMarkedForUnmountInCurrentTransaction) BOOL markedForUnmountInCurrentTransaction; +@property (nonatomic) BOOL snapshotAfterUpdates; #else @property (nonatomic, copy) RCTDirectEventBlock onAppear; @property (nonatomic, copy) RCTDirectEventBlock onDisappear; diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 65c18f1ddc..e8779d92d4 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -2139,12 +2139,12 @@ - (RNSOrientation)evaluateOrientation #ifdef RCT_NEW_ARCH_ENABLED #pragma mark - Fabric specific -- (void)setViewToSnapshot +- (void)setViewToSnapshotAfterUpdates:(BOOL)afterUpdates { UIView *superView = self.view.superview; // if we dismissed the view natively, it will already be detached from view hierarchy if (self.view.window != nil) { - UIView *snapshot = [self.view snapshotViewAfterScreenUpdates:NO]; + UIView *snapshot = [self.view snapshotViewAfterScreenUpdates:afterUpdates]; snapshot.frame = self.view.frame; [self.view removeFromSuperview]; self.view = snapshot; diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index 51f021831a..db0e68204a 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -1393,7 +1393,8 @@ - (nullable RNSScreenView *)childScreenForTag:(react::Tag)tag - (void)unmountChildComponentView:(UIView *)childComponentView index:(NSInteger)index { RNSScreenView *screenChildComponent = (RNSScreenView *)childComponentView; - [screenChildComponent.controller setViewToSnapshot]; + BOOL afterUpdates = screenChildComponent.snapshotAfterUpdates; + [screenChildComponent.controller setViewToSnapshotAfterUpdates:afterUpdates]; RCTAssert( screenChildComponent.reactSuperview == self, From 3eb252f6111f39524729b2c1eb93a898f825d6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20B=C5=82oniarz?= Date: Tue, 4 Nov 2025 11:17:13 +0100 Subject: [PATCH 2/3] Just read it from the screenView --- ios/RNSScreen.h | 2 +- ios/RNSScreen.mm | 4 +++- ios/RNSScreenStack.mm | 3 +-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ios/RNSScreen.h b/ios/RNSScreen.h index c0bbf0d08a..4647fe6a3b 100644 --- a/ios/RNSScreen.h +++ b/ios/RNSScreen.h @@ -53,7 +53,7 @@ namespace react = facebook::react; - (void)notifyFinishTransitioning; - (RNSScreenView *)screenView; #ifdef RCT_NEW_ARCH_ENABLED -- (void)setViewToSnapshotAfterUpdates:(BOOL)afterUpdates; +- (void)setViewToSnapshot; - (CGFloat)calculateHeaderHeightIsModal:(BOOL)isModal; #endif diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index e8779d92d4..433d70e5bf 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -98,6 +98,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { static const auto defaultProps = std::make_shared(); + _snapshotAfterUpdates = NO; _props = defaultProps; _reactSubviews = [NSMutableArray new]; _contentWrapperBox = {}; @@ -2139,11 +2140,12 @@ - (RNSOrientation)evaluateOrientation #ifdef RCT_NEW_ARCH_ENABLED #pragma mark - Fabric specific -- (void)setViewToSnapshotAfterUpdates:(BOOL)afterUpdates +- (void)setViewToSnapshot { UIView *superView = self.view.superview; // if we dismissed the view natively, it will already be detached from view hierarchy if (self.view.window != nil) { + auto afterUpdates = self.screenView.snapshotAfterUpdates; UIView *snapshot = [self.view snapshotViewAfterScreenUpdates:afterUpdates]; snapshot.frame = self.view.frame; [self.view removeFromSuperview]; diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index db0e68204a..51f021831a 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -1393,8 +1393,7 @@ - (nullable RNSScreenView *)childScreenForTag:(react::Tag)tag - (void)unmountChildComponentView:(UIView *)childComponentView index:(NSInteger)index { RNSScreenView *screenChildComponent = (RNSScreenView *)childComponentView; - BOOL afterUpdates = screenChildComponent.snapshotAfterUpdates; - [screenChildComponent.controller setViewToSnapshotAfterUpdates:afterUpdates]; + [screenChildComponent.controller setViewToSnapshot]; RCTAssert( screenChildComponent.reactSuperview == self, From cee931ec1620a57ed284e02be7ff5625ecd39096 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Tue, 4 Nov 2025 12:12:42 +0100 Subject: [PATCH 3/3] Add comment that this property was added for the sake of reanimated --- ios/RNSScreen.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ios/RNSScreen.h b/ios/RNSScreen.h index a7f713a8d9..9946854d87 100644 --- a/ios/RNSScreen.h +++ b/ios/RNSScreen.h @@ -131,6 +131,11 @@ namespace react = facebook::react; @property (nonatomic, readonly) BOOL hasHeaderConfig; @property (nonatomic, readonly, getter=isMarkedForUnmountInCurrentTransaction) BOOL markedForUnmountInCurrentTransaction; + +/** + * Whether the snapshot for the transition made for JS-popped views should be taken after view updates or not. + * *This property was introduced for the sake of integration with reanimated.* + */ @property (nonatomic) BOOL snapshotAfterUpdates; #else @property (nonatomic, copy) RCTDirectEventBlock onAppear;