Login And logout With Drawer navigation in react native

742 views Asked by At

My main issue is after login i want to hide the login from drawer bar and instead of login want to show logout,

<Drawer.Navigator>    
  <Drawer.Screen name="Login" component={LoginScreen} />
  <Drawer.Screen name="OrderList">{() => (
    <Tab.Navigator initialRouteName="OrderList">
      <Tab.Screen name="OrderList" component={CompletedScreen} />
      <Tab.Screen name="Pending" component={PendingScreen} />
    </Tab.Navigator>)}
  </Drawer.Screen>
  <Drawer.Screen name="EditOrder" component={SingleOrderScreen} />
  <Drawer.Screen name="Logout" component={LogoutScreen} />
</Drawer.Navigator>
1

There are 1 answers

0
Nooruddin Lakhani On

This might help

<Drawer.Navigator>
    {isLoggedIn ? (
      <>
        <Drawer.Screen name="Logout" component={LogoutScreen} />
      </>
     ) : (
      <>
        <Drawer.Screen name="Login" component={LoginScreen} />
      </>
    )}
<Drawer.Screen name="OrderList">{() => (
    <Tab.Navigator initialRouteName="OrderList">
      <Tab.Screen name="OrderList" component={CompletedScreen} />
      <Tab.Screen name="Pending" component={PendingScreen} />
    </Tab.Navigator>)}
  </Drawer.Screen>
  <Drawer.Screen name="EditOrder" component={SingleOrderScreen} />
</Drawer.Navigator>