I am creating a mobile app in React Native. But I am facing a navigation problem.
I currently have a navigation stack ‘A’ that contains screen 1, screen 2 and navigation stack B.With in stack B, screen 3 and 4.
If I start on screen 1 (stack A) and navigate to screen 3 (stack B) and back. There is no problem yet. But if I now navigate from screen ‘1’ to screen ‘4’. The back button goes back to screen 3 instead of screen 1.
Normaly if you use navigation.goBack() the current screen gets removed from that stack.
But it seems that if you navigate back from the last screen in that stack, that doesn’t happen.
I tried to navigate from screen 1 to screen 3 with navigation.reset() but this clears all the navigation stacks and not only the second one.
navigation.reset(
{
index: 0,
routes: [{ name: 'Screen3' }],
},
0
);
How can I clear only one navigation stack?
Or is there a better way to handel this?