theMikeSwan
theMikeSwan

Reputation: 4729

How do you pop to a specific screen in react-navigation StackNavigator?

I am trying to find StackNavigator's to UINavigationContoller's popToViewController(_ viewController: UIViewController, animated: Bool).

According to the docs goBack() only ever goes back one position, the argument you pass in is where you are going back from rather than where you want to go back to.

There are no tabs or nesting of navigators just a simple A->B->C->D->E with the ability to go back to any of the previous screens from E.

Upvotes: 2

Views: 6912

Answers (1)

Yousaf Masud
Yousaf Masud

Reputation: 169

You could actually make use of the navigation.navigate function

Another common requirement is to be able to go back multiple screens -- for example, if you are several screens deep in a stack and want to dismiss all of them to go back to the first screen. In this case, we know that we want to go back to Home so we can use navigate('Home')

https://reactnavigation.org/docs/en/navigating.html

Upvotes: 4

Related Questions