0

How do you Navigate out of a Nested(ish) StackNavigator and DrawerNavigator, and disable the back key so that the user can't go back to the previous screen?

Below is the view hierarchy:

const login = StackNavigator(
  {
    loginScreen: { screen: Login },
    firstPage: { screen: CodeCollab },
  },
  {
    initialRouteName: "firstPage"
  }
)

const main = StackNavigator(
  {
    home: { screen: Home },
  }
)

const homeDrawer = DrawerNavigator(
  {
    first: { screen: main },
  },
  {
    contentComponent: DrawerContent
  }
)

const out = StackNavigator(
  {
    Login: login,
    Home: homeDrawer,
    split: Splitter
  },
  {
    headerMode: 'none',
    title: 'Main',
    initialRouteName: "split"
  }
)

export default out

I'm trying to go from login/loginScreen to out/Home

Qin Guan
  • 41
  • 1
  • 2
  • Possible duplicate of [React-Navigation with Login Screen](https://stackoverflow.com/questions/42876690/react-navigation-with-login-screen) – bennygenel May 24 '18 at 16:34

1 Answers1

0

Try this code:

this.props.navigation.dispatch(NavigationActions.back());
Vikram Biwal
  • 2,618
  • 1
  • 25
  • 36