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

Can't reset and pass props to children scenes under Tab nav #2935

Closed
simonso3 opened this issue Mar 13, 2018 · 4 comments
Closed

Can't reset and pass props to children scenes under Tab nav #2935

simonso3 opened this issue Mar 13, 2018 · 4 comments

Comments

@simonso3
Copy link

Version

Tell us which versions you are using:

  • react-native-router-flux v4.0.0-beta.27 (v3 is not supported)
  • react-native v0.52.2

Expected behaviour

...
<Stack key="root">
  <LoginScreen initial/>
  <Tab>
    <Stack>
      <HomeScreen/>
       ...
    </Stack>
     ...
  </Tab>
</Stack>
...

Above is the simplified version of my scenes.
Start at the LoginScreen, here is my goal:

1) Pass props (login stuff) from LoginScreen to HomeScreen

2) RESET the stack so the user can't go back to the Login screen once the user landed on HomeScreen

So I tried doing:

Attempt 1) Actions.reset('HomeScreen', params);

I expected:

  • No error
  • the stack being reset so users can't go back to LoginScreen
  • HomeScreen is loaded with the params

Attempt 2) Actions.HomeScreen(params);

  • this doesn't give me any error and HomeScreen is loaded with the params but it doesn't reset the stack so users can still go back to Loading screen onBack (e.g. hardwareBack on Android)

Attempt 3) Actions.reset('Tab', params);

I expected:

  • the stack being reset so users can't go back to LoginScreen
  • Though props are being passed to Tab but I expect/want a way to pass the props down to the children scenes under Tab.

Actual behaviour

  1. This gave me and error as There is no route defined and it can only be ....
  2. This is actually doing what I expected, however I just want to find a way to reset the stack in the same time
  3. Params are not being passed down to the children scenes under Tab

Steps to reproduce

For non-obvious bugs, please fork this component, modify Example project to reproduce your issue and include link here.

  1. Do the same setup as above
  2. Perform attempt 1,2,3 stated above
@asciifaceman
Copy link
Contributor

asciifaceman commented Mar 13, 2018

The way I've begun handling this personally is to use a Launch.js that loads first. This view simply checks to see if the app is already logged in, if it isn't, then it goes to LoginView. If it IS then it continues to the authenticated view.

After a login, I pop the user back to Launch.js which rechecks and then shunts to the authenticated view.

This is helpful because even if the user somehow manages to "go back to the beginning" it just rechecks auth and sends them back to their view. LoginView is ONLY accessible if you are not authenticated.

screen shot 2018-03-13 at 10 49 54 am

hope this helps

@simonso-nzme
Copy link

@asciifaceman Thanks for the reply! I was using LoginScreen to simplified my example, is actually a loading screen that initialise the app. The approach you mentioned is a good solution, though I would prefer having the RESET functionality to work properly so I don't have to worry about it once the user got to HomeScreen. I've been looking around but it seems that the bug still exists in RESET and I haven't found a way to pass props from Tabs to its children Scenes. :(

@amarkovits
Copy link

I also have this problem. Cant reset/replace to a tabs scene because the props are not passed to the children

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

Please try to reproduce it with Example project and latest version 4.0.0-beta.40. Feel free to open if the issue still exists

To 'reset' stack you can use type='replace' for your Tab, so user cannot go back.

@aksonov aksonov closed this as completed Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants