From d2ded8fe6aa5c5a5189d608f91e03da6fb4d622d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Boro=C5=84?= Date: Mon, 3 Nov 2025 15:58:00 +0100 Subject: [PATCH 1/5] Migrate --- ios/RNSScreen.mm | 11 +++++++++ ios/RNSScreenStack.mm | 54 +++++++++++++++++++++++++------------------ 2 files changed, 43 insertions(+), 22 deletions(-) diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index a432b151a8..d36afcbedc 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -28,8 +28,10 @@ #import #import #import +#import #import "RNSConversions.h" +#import "RNSReactNativeVersionUtils.h" #import "RNSSafeAreaViewNotifications.h" #import "RNSScreenFooter.h" #import "RNSScreenStack.h" @@ -1509,6 +1511,15 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask #endif // !TARGET_OS_TV && !TARGET_OS_VISION } +#if REACT_NATIVE_VERSION_MINOR >= 82 +- (void)invalidate +{ + if (!facebook::react::is082PrereleaseOrLower()) { + [self invalidateImpl]; + } +} +#endif // REACT_NATIVE_VERSION_MINOR >= 82 + #pragma mark - Paper specific #else diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index 6d4edacc02..c1effec4fa 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -20,8 +20,10 @@ #import "RCTTouchHandler+RNSUtility.h" #endif // RCT_NEW_ARCH_ENABLED +#import #import "RNSDefines.h" #import "RNSPercentDrivenInteractiveTransition.h" +#import "RNSReactNativeVersionUtils.h" #import "RNSScreen.h" #import "RNSScreenStack.h" #import "RNSScreenStackAnimator.h" @@ -210,13 +212,13 @@ @implementation RNSScreenStackView { RNSPercentDrivenInteractiveTransition *_interactionController; __weak RNSScreenStackManager *_manager; BOOL _updateScheduled; -#ifdef RCT_NEW_ARCH_ENABLED +#if RCT_NEW_ARCH_ENABLED && REACT_NATIVE_VERSION_MINOR <= 82 /// Screens that are subject of `ShadowViewMutation::Type::Delete` mutation /// in current transaction. This vector should be populated when we receive notification via /// `RCTMountingObserving` protocol, that a transaction will be performed, and should /// be cleaned up when we're notified that the transaction has been completed. std::vector<__strong RNSScreenView *> _toBeDeletedScreens; -#endif // RCT_NEW_ARCH_ENABLED +#endif // RCT_NEW_ARCH_ENABLED && REACT_NATIVE_VERSION_MINOR <= 82 } #ifdef RCT_NEW_ARCH_ENABLED @@ -1369,15 +1371,19 @@ - (void)unmountChildComponentView:(UIView *)childCompo - (void)mountingTransactionWillMount:(const facebook::react::MountingTransaction &)transaction withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry { - for (const auto &mutation : transaction.getMutations()) { - if (mutation.type == react::ShadowViewMutation::Delete) { - RNSScreenView *_Nullable toBeRemovedChild = [self childScreenForTag:mutation.oldChildShadowView.tag]; - if (toBeRemovedChild != nil) { - [toBeRemovedChild willBeUnmountedInUpcomingTransaction]; - _toBeDeletedScreens.push_back(toBeRemovedChild); +#if REACT_NATIVE_VERSION_MINOR <= 82 + if (facebook::react::is082PrereleaseOrLower()) { + for (const auto &mutation : transaction.getMutations()) { + if (mutation.type == react::ShadowViewMutation::Delete) { + RNSScreenView *_Nullable toBeRemovedChild = [self childScreenForTag:mutation.oldChildShadowView.tag]; + if (toBeRemovedChild != nil) { + [toBeRemovedChild willBeUnmountedInUpcomingTransaction]; + _toBeDeletedScreens.push_back(toBeRemovedChild); + } } } } +#endif // REACT_NATIVE_VERSION_MINOR <= 82 } - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction &)transaction @@ -1400,24 +1406,28 @@ - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction } } - if (!self->_toBeDeletedScreens.empty()) { - __weak RNSScreenStackView *weakSelf = self; - // We want to run after container updates are performed (transitions etc.) - dispatch_async(dispatch_get_main_queue(), ^{ - RNSScreenStackView *_Nullable strongSelf = weakSelf; - if (strongSelf == nil) { - return; - } - for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) { +#if REACT_NATIVE_VERSION_MINOR <= 82 + if (facebook::react::is082PrereleaseOrLower()) { + if (!self->_toBeDeletedScreens.empty()) { + __weak RNSScreenStackView *weakSelf = self; + // We want to run after container updates are performed (transitions etc.) + dispatch_async(dispatch_get_main_queue(), ^{ + RNSScreenStackView *_Nullable strongSelf = weakSelf; + if (strongSelf == nil) { + return; + } + for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) { #ifdef RCT_NEW_ARCH_ENABLED - [screenRef invalidateImpl]; + [screenRef invalidateImpl]; #else - [screenRef invalidate]; + [screenRef invalidate]; #endif - } - strongSelf->_toBeDeletedScreens.clear(); - }); + } + strongSelf->_toBeDeletedScreens.clear(); + }); + } } +#endif // REACT_NATIVE_VERSION_MINOR <= 82 } - (void)prepareForRecycle From 2eac5a63c809035b6bf2737dca07c5bbe11b94c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Boro=C5=84?= Date: Mon, 3 Nov 2025 16:00:41 +0100 Subject: [PATCH 2/5] Delay --- ios/RNSScreen.mm | 11 +++++++++-- ios/RNSScreenStack.mm | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index d36afcbedc..94a0b41cd5 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -938,8 +938,15 @@ - (BOOL)isTransparentModal - (void)invalidateImpl { - _controller = nil; - [_sheetsScrollView removeObserver:self forKeyPath:@"bounds" context:nil]; + // We want to run after container updates are performed (transitions etc.) + __weak auto weakSelf = self; + dispatch_async(dispatch_get_main_queue(), ^{ + auto strongSelf = weakSelf; + if (strongSelf) { + strongSelf->_controller = nil; + [strongSelf->_sheetsScrollView removeObserver:self forKeyPath:@"bounds" context:nil]; + } + }); } #ifndef RCT_NEW_ARCH_ENABLED diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index c1effec4fa..9ed6da3cf7 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -1420,7 +1420,7 @@ - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction #ifdef RCT_NEW_ARCH_ENABLED [screenRef invalidateImpl]; #else - [screenRef invalidate]; + [screenRef invalidate]; #endif } strongSelf->_toBeDeletedScreens.clear(); From e1cd715f26875bc73c8fdc9ad59a6d4f53af70ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Boro=C5=84?= Date: Tue, 4 Nov 2025 09:56:01 +0100 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Krzysztof Ligarski <63918941+kligarski@users.noreply.github.com> --- ios/RNSScreen.mm | 2 +- ios/RNSScreenStack.mm | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 94a0b41cd5..4bdfd7b4d1 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -949,7 +949,7 @@ - (void)invalidateImpl }); } -#ifndef RCT_NEW_ARCH_ENABLED +#if !RCT_NEW_ARCH_ENABLED - (void)invalidate { [self invalidateImpl]; diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index 9ed6da3cf7..c6d44401c6 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -1417,11 +1417,11 @@ - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction return; } for (RNSScreenView *screenRef : strongSelf->_toBeDeletedScreens) { -#ifdef RCT_NEW_ARCH_ENABLED +#if RCT_NEW_ARCH_ENABLED [screenRef invalidateImpl]; -#else +#else // RCT_NEW_ARCH_ENABLED [screenRef invalidate]; -#endif +#endif // RCT_NEW_ARCH_ENABLED } strongSelf->_toBeDeletedScreens.clear(); }); From 1e0db9ff7df3d29f3307c44832dd8c735c44d8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Boro=C5=84?= Date: Tue, 4 Nov 2025 09:58:52 +0100 Subject: [PATCH 4/5] Add comment --- ios/RNSScreen.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ios/RNSScreen.mm b/ios/RNSScreen.mm index 4bdfd7b4d1..8854ec2560 100644 --- a/ios/RNSScreen.mm +++ b/ios/RNSScreen.mm @@ -954,7 +954,7 @@ - (void)invalidate { [self invalidateImpl]; } -#endif +#endif // !RCT_NEW_ARCH_ENABLED #if !TARGET_OS_TV && !TARGET_OS_VISION From f254735ef7df43f72f1003473e8975b19fe80db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Boro=C5=84?= Date: Tue, 4 Nov 2025 10:01:15 +0100 Subject: [PATCH 5/5] Formatting --- ios/RNSScreenStack.mm | 2 +- ios/bottom-tabs/RNSBottomTabsScreenComponentView.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios/RNSScreenStack.mm b/ios/RNSScreenStack.mm index c6d44401c6..76ce967247 100644 --- a/ios/RNSScreenStack.mm +++ b/ios/RNSScreenStack.mm @@ -1421,7 +1421,7 @@ - (void)mountingTransactionDidMount:(const facebook::react::MountingTransaction [screenRef invalidateImpl]; #else // RCT_NEW_ARCH_ENABLED [screenRef invalidate]; -#endif // RCT_NEW_ARCH_ENABLED +#endif // RCT_NEW_ARCH_ENABLED } strongSelf->_toBeDeletedScreens.clear(); }); diff --git a/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h b/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h index c8d4fb0552..e0d4227b2e 100644 --- a/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h +++ b/ios/bottom-tabs/RNSBottomTabsScreenComponentView.h @@ -14,7 +14,7 @@ #if REACT_NATIVE_VERSION_MINOR <= 82 #import "RNSViewControllerInvalidating.h" #endif // REACT_NATIVE_VERSION_MINOR <= 82 -#else // RCT_NEW_ARCH_ENABLED +#else // RCT_NEW_ARCH_ENABLED #import #endif // RCT_NEW_ARCH_ENABLED