Skip to content

Commit

Permalink
refactor(iOS, Paper): do not add subviews to header config in HostTree (
Browse files Browse the repository at this point in the history
#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: <!-- For adding new props to native-stack
-->
- [ ]
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
  • Loading branch information
kkafar authored Dec 6, 2024
1 parent 8c43de6 commit 20808ee
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ios/RNSScreenStackHeaderConfig.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -1050,6 +1044,11 @@ - (void)updateState:(const facebook::react::State::Shared &)state
#else
#pragma mark - Paper specific

- (void)didUpdateReactSubviews
{
[self updateViewControllerIfNeeded];
}

- (void)didSetProps:(NSArray<NSString *> *)changedProps
{
[super didSetProps:changedProps];
Expand Down

0 comments on commit 20808ee

Please sign in to comment.