从抽屉导航器返回登录屏幕

时间:2020-07-05 00:15:17

标签: react-native navigation-drawer drawer react-navigation-v5 react-navigation-drawer

我有一个带3个屏幕的Stacknavigator,其中一个是Main,是一个具有自定义抽屉内容的抽屉导航器,并且在带有退出按钮的抽屉项中。如何返回登录屏幕?道具我可以访问抽屉堆栈,但不能访问主堆栈,如LoginScreen

const AppNavigator = createStackNavigator(
  {
  LoginScreen: { screen: Login },
  Main: { screen: Main },
  Register: {screen: RegisterScreen}
  },
  {
    headerMode: 'none',
  },
  {
    initialRouteName: 'LoginScreen',
    }
);
function DrawerScreen  (props) {

  return(
  <Drawer.Navigator
   drawerContent={(props)=> <DrawerContent {...props}/>}
    initialRouteName="Home"    >
    <Drawer.Screen name="Home" component={CuentaScreen}/>
    <Drawer.Screen name="Profile" component={NotificationsScreen} />
    <Drawer.Screen name="Register" component={RegisterScreen} />
  </Drawer.Navigator>
  )
};  

0 个答案:

没有答案