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

91
Views
onAuthStateChanged not navigating me to home screen

I have been struggling with this for days now... When I try to login it does not automatically navigate me to home screen, unless I close and open app. I am working with 3 separate components. However after I register once, this issue doesn't occur it only happens with new accounts.

const [userAuth, setUserAuth] = useState()

    useEffect(() => {
        const unsubscribe = auth.onAuthStateChanged(user => {
            user && auth.currentUser?.emailVerified ? setUserAuth(true) : setUserAuth(false)
        })
        return unsubscribe
    })

    return (
        <Provider store={store}>
            <NavigationContainer>
                <Drawer.Navigator>
                    <Drawer.Screen
                        name='main'
                        component={userAuth ? MainDrawer : AuthStack}
                    />
                </Drawer.Navigator>
            </NavigationContainer>
        </Provider>

This is my MainDrawer.js

export default function MainDrawer() {
    return (
        <Drawer.Navigator drawerContent={props => <DrawerScreen {...props} />}>
            <Drawer.Screen
                name='drawer'
                component={HomeStack}
                options={{ headerShown: false }}
            />
        </Drawer.Navigator>
    )
}

This is my HomeStack.js

    <Stack.Navigator initialRouteName='home'>
        <Stack.Screen name='home' component={TabNav}/>
        <Stack.Screen name='about' component={AboutUs}/>
        <Stack.Screen name='faq' component={FaqScreen}/>
        <Stack.Screen name='userTerms' component={TermsScreen} />
        <Stack.Screen name='privacy' component={PrivacyScreen} />
</Stack.Navigator>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe the issue is where you're trying to call onAuthStateChanged, it should be auth().onAuthStateChanged(...). Also, I would change it a little bit

 useEffect(() => {
    const unsubscribe = auth().onAuthStateChanged(firebaseUserResult => {
      firebaseUserResult && firebaseUserResult.emailVerified ? setUserAuth(true) : setUserAuth(false)
    })
    return unsubscribe
  })

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!