0

I have an app with two tabs: Tab1 and Tab2. There are two scenes: scene1 and scene2 as part of my Tab1 group, where scene1 is the initial view. If I navigate to scene2, then press Tab2, then go back to Tab1, it automatically pops scene2 from Tab1 and goes back to scene1 instead of staying on scene2, which is not the behavior I want.

So my question: is there a way in react-native-router-flux where I can prevent the views popping to the root when I press the tab bar item? Ideally it would only pop to the root view when I'm already viewing a view within the same tab bar item. So in the example above, when I press Tab1 the first time it stays on previous existing view, but if I press it again then it pops to the root.

EDIT: including my code

 <Scene key="root">
    <Scene key="tabbar" tabs tabBarStyle={{ backgroundColor: '#FFFFFF' }} >
      <Scene key="osu" title="OSU" icon={TabIcon}>
        <Scene key="scarlet" component={ScarletScreen} title="Scarlet" initial />
        <Scene key="gray" component={GrayScreen} title="Gray" />
      </Scene>
      <Scene key="um" title="UM" icon={TabIcon}>
        <Scene key="blue" component={BlueScreen} title="Blue" initial />
        <Scene key="maize" component={MaizeScreen} title="Maize" />
      </Scene>
    </Scene>
</Scene>
brillajank
  • 43
  • 7
  • I've not experienced this with `react-native-router-flux` before myself. Have you set the `initial` property on your first nested `Scene` within each tab scene group? – fubar Mar 12 '17 at 22:40
  • @Rob yes. My problem is it always jumps back to the initial scene when I go back to the tab scene group, even if I navigated to another scene within the group. So say I have two scenes: scene1 and scene2 as part of my Tab1 group, where scene1 is the initial view. If I navigate to scene2, then press Tab2, then go back to Tab1, it automatically goes back to scene1 instead of staying on scene2. I'm pretty sure this is the default behavior - are you saying this doesn't happen to you? – brillajank Mar 12 '17 at 23:00
  • It definitely doesn't happen for me. And you have a tabs property set on your wrapping scenes? See answer for code example. – fubar Mar 12 '17 at 23:06

1 Answers1

3

Thanks to @Rob for helping me figure this out... If anyone else is experiencing this issue, just tested it in on the previous version 3.37.0 and that fixed the issue (I was using 3.38.0). However, 3.37.0 has the issue mentioned on here where tapping a tab while you're already viewing it doesn't pop back to default scene. It appears that by attempting to resolve that issue in version 3.38.0 it caused the above issue I posted about. So I guess you for now you have to decide which is the least objectionable, but hopefully they'll address both cases in later versions...

brillajank
  • 43
  • 7