Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!