StackActions.popToRouteName(routeName)
slorber opened this issue · 2 comments
Hi,
I think having a StackActions.popToRouteName(routeName)
in core would be convenient.
It would just be a shortcut to StackActions.pop(x)
with x automatically precomputed to the last stack screen that match the route name.
The idea is that sometimes, you are on a stack screen and you generally know that you want to go back to some screen that you know exist in the stack, but you don't necessarily know how much you need to go back to reach it.
In my case, I have a screen EventPhotoScreen
, and I need to go back to some former screen EventRootScreen
in the stack. Sometimes I need to pop 1 screen, sometimes, I need to pop 2 screens, depending on whether there is an "intermediate screen" between the 2... But my "intent" is to go back to a screen named EventRootScreen
.
I think react-navigation should let me express my intent more clearly for this usecase, instead of having to compute how much screens I need to pop in userland, ability to pop to a specific screen name would be convenient).
Maybe the same could apply for other cases and we would want to pop to specific key/index as well (but this is not my own usecase)
can't you just do navigate('RouteName')
for this? if the route already exists then it will pop however many screens it needs to in order to get back there
Ah this works? Didn't know that navigate could go back.
I guess it changed when navigate became less pushy. Thanks will try that and reopen if needed