-
-
Notifications
You must be signed in to change notification settings - Fork 523
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: remove unnecessary checks for creating snapshot #2485
fix: remove unnecessary checks for creating snapshot #2485
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.
I think we need to work on improving this code 👇🏻
screenChildComponent == [_presentedModals.lastObject view])) { | ||
[screenChildComponent.controller setViewToSnapshot]; | ||
} | ||
[screenChildComponent.controller setViewToSnapshot]; |
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.
I see that this simplifies the logic, but I don't think this is quite right.
Imagine you have Stack with three screens: "A, B, C". You pop from C to top, thus resulting stack is "A". This code would do snapshots of both C and B, while we only want to do a snapshot of C.
If you describe what problem exactly you intend to solve we might be able to figure out better solution.
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.
Will this code:
react-native-screens/ios/RNSScreen.mm
Line 1842 in 4614702
if (self.view.window != nil) { |
true
for B
? I think its view is not in the window since it is detached. Would have to check though.
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.
I checked. It is nil
then so it should work correctly.
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.
+1, I've forgotten that UINavigationController will keep all the controllers lower in the stack in detached state and that's it why it will work correctly.
break; | ||
default: | ||
RCTLogError(@"[RNScreens] Unhandled subview type: %ld", childComponentView.type); | ||
if (childComponentView.window != nil) { |
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.
Also added this check since we got many warning of snapshotting a view that is not in hierarchy when dismissing many screens with header items at once.
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're good then. Thanks for answering my concerns.
screenChildComponent == [_presentedModals.lastObject view])) { | ||
[screenChildComponent.controller setViewToSnapshot]; | ||
} | ||
[screenChildComponent.controller setViewToSnapshot]; |
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.
+1, I've forgotten that UINavigationController will keep all the controllers lower in the stack in detached state and that's it why it will work correctly.
I've restarted the CI & we need to update the podfile lock. |
Description
Based on Expensify/App#49937 (comment) and the comments above, PR fixes the unnecessary checks for creating snapshot on the view on dismiss. It was refactored already in #2134 and #2261 (👏 to @kkafar). Those checks do nothing now since each screen is responsible for making its own snapshot. Having those checks can only lead to problems.