3

So, i need to reset navigation stack each time a tab is selected from the tab navigation. Right now it works like this:

User is on Tab A -> Opened New Screen (i.e. News) on Tab A -> Selected Tab B -> Selected Tab A and came back to last opened screen (News) instead of coming back to Tab A .

I need to change the last step and reset the opened screens each time user selects new Tab.

i know that there are few API items that i can use for it, like pop, popToRoot and resetTo but i have no idea how to use it correctly.

Can someone give me an example that i can use it?

Thanks in advance!

Ziya
  • 324
  • 3
  • 14

1 Answers1

3

Listen to BottomTabSelected event and call this.props.navigator.popToRoot.

guy.gc
  • 3,359
  • 2
  • 24
  • 39
  • Hello and thanks for answering. I wanted to follow up: is it possible to reset the stack with `popToRoot` to the certain tab? – Ziya Mar 11 '19 at 11:34
  • In v2 you can pop to a specific component using [popTo](https://wix.github.io/react-native-navigation/#/docs/screen-api?id=poptocomponentid-mergeoptions) – guy.gc Mar 11 '19 at 12:25