From 20808ee84547ad5c48b4bbc67d9e0f6dc403ee58 Mon Sep 17 00:00:00 2001 From: Kacper Kafara Date: Fri, 6 Dec 2024 23:56:51 +0100 Subject: [PATCH] refactor(iOS, Paper): do not add subviews to header config in HostTree (#2553) ## Description I was just writing #2552 and got confused that the header config subviews are added as subviews to the header config view in host tree, before they are attached to the navigation bar view hierarchy. This transient state does not make any sense, and we do not do similar thing on Fabric. ## Changes `self.superview` returns now `nil` until the subview is mounted in navigation bar view hierarchy. Also moved the function to Paper specific section of file, because it is not called on Fabric on any codepath. ## Test code and steps to reproduce We haven't used this behaviour. There should be no regression in text examples. ## Checklist - [ ] Included code example that can be used to test this change - [ ] Updated TS types - [ ] Updated documentation: - [ ] https://github.com/software-mansion/react-native-screens/blob/main/guides/GUIDE_FOR_LIBRARY_AUTHORS.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/native-stack/README.md - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/types.tsx - [ ] https://github.com/software-mansion/react-native-screens/blob/main/src/native-stack/types.tsx - [ ] Ensured that CI passes --- ios/RNSScreenStackHeaderConfig.mm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ios/RNSScreenStackHeaderConfig.mm b/ios/RNSScreenStackHeaderConfig.mm index 0107bb84c..bda667a2e 100644 --- a/ios/RNSScreenStackHeaderConfig.mm +++ b/ios/RNSScreenStackHeaderConfig.mm @@ -828,12 +828,6 @@ - (void)removeReactSubview:(RNSScreenStackHeaderSubview *)subview } RNS_IGNORE_SUPER_CALL_BEGIN -- (void)didUpdateReactSubviews -{ - [super didUpdateReactSubviews]; - [self updateViewControllerIfNeeded]; -} - #ifdef RCT_NEW_ARCH_ENABLED #pragma mark - Fabric specific @@ -1050,6 +1044,11 @@ - (void)updateState:(const facebook::react::State::Shared &)state #else #pragma mark - Paper specific +- (void)didUpdateReactSubviews +{ + [self updateViewControllerIfNeeded]; +} + - (void)didSetProps:(NSArray *)changedProps { [super didSetProps:changedProps];