-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(iOS): header snapshots not working #2393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, I need you to confirm that this PR does not introduce regression on #2230.
You can test specifically on @tboba's reproduction: #2230 (comment)
If we don't have a regression I need you to explain what other change fixed the issue mentioned in #2230. Otherwise I'm a bit reluctant, cause it might be working only by accident.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few remarks. The logic looks good, I would only want you to change the naming.
ios/RNSScreen.h
Outdated
@@ -100,6 +100,7 @@ namespace react = facebook::react; | |||
@property (nonatomic) react::LayoutMetrics newLayoutMetrics; | |||
@property (weak, nonatomic) RNSScreenStackHeaderConfig *config; | |||
@property (nonatomic, readonly) BOOL hasHeaderConfig; | |||
@property (nonatomic) BOOL isGoingToBeRemoved; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this in public API of Screen component
@property (nonatomic) BOOL isGoingToBeRemoved; |
Co-authored-by: Kacper Kafara <[email protected]>
The `updateViewControllerIfNeeded` call introduced by #2230 forces the view controller to rebuild the subviews with the recent config. When the screen is being unmounted it replaces the subviews with nil values as the `reactSubviews` are removed from the config one by one. Snapshots made earlier get discarded in the process. This PR adds a condition that prevents updating the view controller when the screen is being changed + stops unnecessary snapshots when the screen is not changed. - updated `Test556.tsx` repro - added `isGoingToBeRemoved` property to `RNSScreenView` - making snapshots / updating the view controller conditionally <!-- --> - Use `Test556.tsx` repro - [x] Included code example that can be used to test this change - [x] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]> Co-authored-by: Kacper Kafara <[email protected]> (cherry picked from commit e4333a1)
Description
The
updateViewControllerIfNeeded
call introduced by #2230 forces the view controller to rebuild the subviews with the recent config.When the screen is being unmounted it replaces the subviews with nil values as the
reactSubviews
are removed from the config one by one. Snapshots made earlier get discarded in the process.This PR adds a condition that prevents updating the view controller when the screen is being changed + stops unnecessary snapshots when the screen is not changed.
Changes
Test556.tsx
reproisGoingToBeRemoved
property toRNSScreenView
Test code and steps to reproduce
Test556.tsx
reproChecklist