0

I am having issue with react-native-router-flux, the problem is that suppose in a single module if there are 3 scenes I am navigating from scene1 -> scene2 and scene2->scene3 further scene3->scene2 again scene2->scene3 and now press on back button. What it is doing is on Actions.pop() is moving from scene3->scene2->scene3->scene2->scene1.

Although i want it to move from scene3->scene2->scene1 and not the entire history. I want to know this can be done in react-native using react-native-router-flux.

Ratnesh K Sinha
  • 51
  • 1
  • 10

2 Answers2

0

The default action for the router is pushing a scene onto a navigation stack. Thus the behavior you are describing is expected and correct.

Sounds like what you want instead should be three tabs that we can switch among each other, because they are independent of each other.

One way is to look up how RNRF does tabs. Check he example app here https://github.com/aksonov/react-native-router-flux/blob/master/README.md#try-the-example-app for how it’s done. Another way might be using something like https://github.com/skv-headless/react-native-scrollable-tab-view

hyb175
  • 1,291
  • 8
  • 13
0

To add to what @hyb175 said, although the behaviour is as expected, it is quite unintuitive for a non mobile developer. E.g. logging out a user should not create multiple screens. The example app provides a straightforward albeit undocumented solution.

Actions.popTo('<screen_key>')

I am unsure what happens to other screens, and I will update it once I test it out a bit more.

I wish the documentation was more fleshed out.

-k

Arif Amirani
  • 26,265
  • 3
  • 33
  • 30