Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
How to Check the login state?

I have a navigator as below. I want to show the drawer when the user logged in. However, the isLogin will still be false after I login. As I am quit new to react native, is there any solution to this issue? Also, I want to know if there are any good sources for learning react native?

let isLogin = firebase.auth().currentUser ? true : false;

const HomeStack = () => {
  return (
    <Stack.Navigator
      screenOptions={{
        headerStyled: {
          backgroundColor: primary,
        },
        headerLeftContainerStyle: {
          paddingLeft: 20,
        },
        headerShown: false,
      }}
      initialRouteName="Home"
    >
      <Stack.Screen name="HomeScreen" component={Home} />
      <Stack.Screen name="Login" component={Login} />
    </Stack.Navigator>
  );
};
console.log(isLogin);
const LoginStack = () => {
  return (
    <Stack.Navigator
      screenOptions={{
        headerStyled: {
          backgroundColor: primary,
        },
        headerLeftContainerStyle: {
          paddingLeft: 20,
        },
        headerShown: false,
      }}
      initialRouteName="Login"
    >
      <Stack.Screen name="Login" component={Login} />
      <Stack.Screen name="Signup" component={Signup} />
      <Stack.Screen name="Home" component={Home} />
    </Stack.Navigator>
  );
};
const RootStack = () => {
  return (
    <NavigationContainer>
      {/* {isLogin ? (
        <Drawer.Navigator>
          <Drawer.Screen name="Home" component={HomeStack} />
          <Drawer.Screen name="Chat" component={Chat} />
        </Drawer.Navigator>
      ) : (
        <LoginStack />
      )} */}
      <LoginStack />
    </NavigationContainer>
  );
};

export default RootStack;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Because you initialize isLogin variable outside the component, you get value only one time. So you need to put declaring variable into the component.

const RootStack = () => {
  let isLogin = firebase.auth().currentUser ? true : false;

  return (
    <NavigationContainer>
      {/* {isLogin ? (
        <Drawer.Navigator>
          <Drawer.Screen name="Home" component={HomeStack} />
          <Drawer.Screen name="Chat" component={Chat} />
        </Drawer.Navigator>
      ) : (
        <LoginStack />
      )} */}
      <LoginStack />
    </NavigationContainer>
  );
};
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda