React-native-router-flux: Reset stack on enter Scene?

Created on 24 Jul 2017  Â·  20Comments  Â·  Source: aksonov/react-native-router-flux

Is it possible to reset the stack when entering on a scene?
I mean, I want to push from a scene to tabbar, but when reach the tabbar, reset the stack.

Is that possible?

I already tried Actions.homeMain({type: ActionConst.RESET})

Didn't work.

needs response from author

Most helpful comment

@luco In my case Actions.reset("homeMain") is working. Try that.

All 20 comments

One way to do it on a route is to just put type='reset' in the Scene, but that doesnt allow you to call a reset when you navigate. I too would like to know the new standard for doing this

@alexwasner Tried that. Didn't work.

Looks like {type: ActionConst.RESET} calls 'replace' now. I've just fixed it for latest master

@luco Have you tried type='replace' for tab bar?

@aksonov Still not working. Tried both type='replace' and {type: ActionConst.RESET}.
Should I remove the plugin and add again?

untitled-1

@luco In my case Actions.reset("homeMain") is working. Try that.

@luco Could you reproduce it with latest Example? I used Actions.tabbar({type:'replace'}) with 4.0.0-beta.14 and tabbar replaces launch screen normally.

@aksonov It gives me this error:

image

My structure is like this:

<Scene key="root" hideNavBar initial>

                  <Scene key="welcome">
                      <Scene key="welcome1" title="" hideNavBar component={Welcome}/>
                  </Scene>

                  <Scene key="tabbar" 
                  tabBarPosition={'bottom'}
                  tabs 
                  showLabel={false} 
                  {...sceneConfig} 
                  tabBarComponent={this.tabBarElement.bind(this)}
                 >

                        <Scene key="home" type="reset" {...sceneConfig}>
                          <Scene key="homeMain" component={Home}/>
...

Remove type='reset' from scenes. Use it as parameter. Again, please reproduce it with current Example project.

@aksonov is this incorrect Actions.reset("homeMain") ? I am able to reset the back stack using it.

@rajsuvariya When I try this method, it only allows me to pick scenes outside my root.

@aksonov Ok, you want to reproduce with example project, but this doesnt solve my problem. I want to understand what im doing wrong.

@aksonov Figured it out. It was the way my Scenes where nested. Had to do this way:

                    <Scene key="start">
                         <Scene key="welcome">
                             <Scene key="welcome1" title="" hideNavBar component={Welcome}/>
                         </Scene>
                      </Scene>

                    <Scene key="root" hideNavBar>

                        <Scene key="tabbar" ...

Last question:
Is there a way to transition and then reset the stack?

Try type='replace'

I'm getting a warning of maximum call stack when I perform a Actions.root({type: ActionConst.RESET});, but nothing with Actions.root().

Do you have idea why?

Nervemind. Typo.
Thanks!

@luco Given your routing structure:

      <Router>
        <Scene key="root" hideNavBar>

          <Scene key="welcome">
            <Scene key="welcome1" title="" hideNavBar component={Welcome} />
          </Scene>

          <Scene key="tabbar" tabBarPosition={'bottom'} tabs >

            <Scene key="home" type="reset" {...sceneConfig}>
              <Scene key="homeMain" component={Home}/>
            </Scene>

          </Scene>
        </Scene>

      </Router>

How did you reset the stack when navigating from

  1. welcome1 -> homeMain (presumably when logging in, ¯_(ツ)_/¯)
  2. homeMain -> welcome1 (presumably when logging out, ¯_(ツ)_/¯)

Actions.usersList({ type:'replace' })

thanks @aksonov sir, your solution worked for me.

@luco In my case Actions.reset("homeMain") is working. Try that.

Tks @rajsuvariya works for me !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rafaelcorreiapoli picture rafaelcorreiapoli  Â·  3Comments

maphongba008 picture maphongba008  Â·  3Comments

sarovin picture sarovin  Â·  3Comments

sylvainbaronnet picture sylvainbaronnet  Â·  3Comments

VictorK1902 picture VictorK1902  Â·  3Comments