React-native-navigation: Remove history screens

Created on 8 Apr 2018  路  4Comments  路  Source: wix/react-native-navigation

The issue below was addressed and had a case where we have A -> B -> C screens, and now we want to go back directly to A screen upon pressing back.
Linked issue

On the linked issue, the solution was to use resetTo which will go back to A and make A root..
Since A was already root, the resetTo really did solve THIS case..

Problem is that I have something like this: A -> B -> C -> D, and want to go back directly to B.
Using resetTo to go to B will make B root, which will not only "remove" C from history, but it will also remove A from history, which is bad for me.

Is there any api I could use for that case? (Going back to B from D and not making B root)

Thanks

Most helpful comment

Hey @omerman
IMO this is an abuse of the stack api. Instead of pushing all screen, do the following:
push A -> push B -> show Modal C -> push D -> dismiss modal
result: A -> B

Regardless, as this question has come up a few times, we've added a popTo(componentId) which will allow you to pop the stack to a specific screen in V2.

All 4 comments

I think you could try pop() multiple times, until you are happy. However that will not be very handy.
Another possible solution would be calling popToRoot first, and then pushing.

But other than that I don't know any other solutions, and that's how I handle my app.

If I do as you suggest I'd end up with a blinking App in the best case. When you do it in your app it doesn't seem to blink badly in that case?

Yeah, maybe it's not that bad, but not the best too.

I think there should be something like popTo function, which basically pops everything, goes to the screen without changing the root.

Hey @omerman
IMO this is an abuse of the stack api. Instead of pushing all screen, do the following:
push A -> push B -> show Modal C -> push D -> dismiss modal
result: A -> B

Regardless, as this question has come up a few times, we've added a popTo(componentId) which will allow you to pop the stack to a specific screen in V2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiroukou picture kiroukou  路  3Comments

EliSadaka picture EliSadaka  路  3Comments

bdrobinson picture bdrobinson  路  3Comments

zhanguangao picture zhanguangao  路  3Comments

viper4595 picture viper4595  路  3Comments