-
-
Notifications
You must be signed in to change notification settings - Fork 585
feat(iOS, Stack): Add controller invalidating to new stack impl #3219
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
base: main
Are you sure you want to change the base?
Conversation
2b07ead
to
4d5bb10
Compare
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 dislike the approach here a bit. I'll want to revisit the structure of the solution at some point. However, since the diff is compatible with what we currently have in other components let's keep it aligned for the moment being.
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, but does it work reliably? What if you pop a screen through JS? Won't it be prematurely invalidated?
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.
no, wait. I've hurried with the approval.
Give me few minutes, I'll write another review
- (void)mountingTransactionWillMount:(const facebook::react::MountingTransaction &)transaction | ||
withSurfaceTelemetry:(const facebook::react::SurfaceTelemetry &)surfaceTelemetry | ||
{ | ||
for (const auto &mutation : transaction.getMutations()) { | ||
if ([self shouldInvalidateOnMutation:mutation]) { | ||
[RNSViewControllerInvalidator invalidateViewIfDetached:self forRegistry:_invalidatedComponentsRegistry]; | ||
} | ||
} | ||
} |
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.
First thing is: why do we have to scan whole list of mutations in every screen component? Why can't we just do it once per transaction in host component?
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.
flushInvalidViews
is triggered when the component is moved out of the window. In such a scenario, the Host will keep all Screens in its registry - we don't know for how long (if the Screen cannot invalidate itself immediately on the mutation, it needs to mark that the mutation came and invalidate on willMoveToWindow: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.
🤔 I don't have good suggestion here unfortunately, but I dislike this solution for it's excessive (hopefully) transaction scanning. I'll try to come up with something better soon. We can discuss this on Monday.
I was testing it on
scenarios and all of them are determined by incoming |
Description
This change adds logic to detach the controller from its component when the component is destroyed. Unlike bottom tabs - where the Host handles detaching controllers from all its children - this approach delegates the responsibility to individual screens. This ensures a quicker response by detaching as soon as the screen is destroyed, rather than keeping views in the registry until the Host is unmounted.
Note: This is a temporary solution and will be replaced once a dedicated callback is available from Meta.
Closes: https://github.com/software-mansion/react-native-screens-labs/issues/127
Changes
RNSViewControllerInvalidating
protocol for stackTest code and steps to reproduce
Verified with logs that the callback is triggered and the controller's reference is removed
Checklist