Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset stack on enter Scene? #2104

Closed
luco opened this issue Jul 24, 2017 · 20 comments
Closed

Reset stack on enter Scene? #2104

luco opened this issue Jul 24, 2017 · 20 comments

Comments

@luco
Copy link
Contributor

luco commented Jul 24, 2017

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.

@alexwasner
Copy link

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

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

@alexwasner Tried that. Didn't work.

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

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

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

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

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

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

untitled-1

@rajsuvariya
Copy link

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

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

@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.

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

@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}/>
...

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

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

@rajsuvariya
Copy link

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

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

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

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

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

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

@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?

@aksonov
Copy link
Owner

aksonov commented Jul 25, 2017

Try type='replace'

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

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?

@luco
Copy link
Contributor Author

luco commented Jul 25, 2017

Nervemind. Typo.
Thanks!

@luco luco closed this as completed Jul 25, 2017
@kumarpatel
Copy link

@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, ¯_(ツ)_/¯)

@anasmp4
Copy link

anasmp4 commented Nov 26, 2017

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

@kalraneeraj24550
Copy link

thanks @aksonov sir, your solution worked for me.

@robleds
Copy link

robleds commented Jun 5, 2019

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

Tks @rajsuvariya works for me !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants