Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.1k
fix: switching navigators nested navigators same route#12128
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
hannojg wants to merge1 commit intoreact-navigation:6.xChoose a base branch frommargelo:fix/switching-navigators-nested-navigators-same-route
base:6.x
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Draft
fix: switching navigators nested navigators same route#12128
hannojg wants to merge1 commit intoreact-navigation:6.xfrommargelo:fix/switching-navigators-nested-navigators-same-route
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
50 tasks
note: the test works if I wait for the cleanup timeout to happen. However, in our original application there is still a bug where after the cleanup another setState is running which is overwriting the state again. Trying to update the test to reflect this edge case. |
6 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
Please provide enough information so that others can review your pull request.
Motivation
When switching navigators there exists a bug where nested state of a screen route isn't cleared.
Imagine you have:
In this case screen
foo
contains a nested navigator.Now, when we switch to another stack, that also contains a screen called
foo
which isn't a nested navigator, the state data with the route won't be cleared from the navigator:If you inspect the navigation state you see that the route "bar" is still there:
We have a use case where we switch between an authenticated and unauthenticated stack. They both share for the initial screen the same screen name.
If the user logs out, and then logs in again, the user will be brought back to the screen where the user left off, as we kept the "bar" route in state.
As we switched to a navigator that doesn't have nested routes, I'd expect the route to be cleared.
Test plan
Adding unit tests to verify the behaviour should be sufficient.
Note: For now I just added a failing unit test. Will provide a fix tmrw! (additional note: this is a fix for expensify)