2

I'm developing a react-native app with react-navigation.

Here is my navigation tree:

Root (StackNavigator)
 -- Login
 -- Main (DrawerNavigator)
 ---- Screen1
 ---- Screen2
 ---- Settings

I have two problems here:

  1. How to reset StackNavigator after user has successfully logged in. So when the user is in Screen1 and presses the back button he doesn't navigate to the login screen again.
  2. How I can navigate from Settings screen to Login screen in order to logout the user?

I'm using React-Navigation v1.2 (and for some particular reason I can't upgrade it to v2).

And here is my code:

const StartNav = StackNavigator({
    Login: { screen: Login },
    Main: { screen: Main },
});

const Main = DrawerNavigator({
    Screen1: {
        screen: Screen1
    },
    Screen2: {
        screen: Screen2
    },
    Setting: {
        screen: Setting
    }
});

Thanks in advance.

1 Answer 1

1

It seems to me you can accomplish everything by simply using a SwitchNavigator? Also from your settings screen you can go back to login by just calling .navigate(Login) and it will find the right one.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.