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
Feature request - popToTop() in other routes #8988
Comments
Couldn't find version numbers for the following packages in the issue:
Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3. |
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
The versions mentioned in the issue for the following packages differ from the latest versions on npm:
Can you verify that the issue still exists after upgrading to the latest versions of these packages? |
I wrote a solution in the stackoverflow question |
In my app I have a bottom tab navigator, and in each tab, I have a stack navigator in each tab.
Is it possible to do .popToTop() over a specific tab's stack from another tab? I mean, for example, if I am in a stack screen "Camera" from one tab, and I navigate to the "Profile" stack screen which is in another tab and has other screens pushed over its root, obviously, I will see these other screens (the state is not resetted)... but doing popToTop() in this specific route (the "Profile" screen) doesn't work for me because I lose all the params that was sent from the "Camera" screen when navigating (the intention was to send them to the root)...
I think this will be great to have something like .popToTop("route-name"); so we can perform this action over any other route.
Maybe, the workaround is to do CommonActions.reset({}), but I don't find any example for React Navigation 5.
Related with: #5114 #6639
The main problem: Reset a stack from another stack before navigating to it.
What I have tried
In the Camera Screen, but I get the error "TypeError: undefined is not an object (evaluating 'nextState.routes.length')"
Full problem explained with a workaround
The main problem is what I have explained avobe, but here I explain my use case and my navigation structure better:
https://stackoverflow.com/questions/64515420/react-navigation-5-reset-a-stack-poptotop-from-another-stack-before-naviga
Current versions I am using:
@react-navigation/compat: 5.2.8
@react-navigation/material-bottom-tabs: 5.2.19
@react-navigation/native: 5.7.6
@react-navigation/stack: 5.9.3
The text was updated successfully, but these errors were encountered: