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

99
Vistas
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 Respuestas
Responde la pregunta

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 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