Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda