He estado luchando con esto durante días... Cuando intento iniciar sesión, no me lleva automáticamente a la pantalla de inicio, a menos que cierre y abra la aplicación. Estoy trabajando con 3 componentes separados. Sin embargo, después de registrarme una vez, este problema no ocurre, solo ocurre con cuentas nuevas.
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>Este es mi 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>Creo que el problema es cuando intentas llamar a onAuthStateChanged , debería ser auth().onAuthStateChanged(...) . Además, lo cambiaría un poco.
useEffect(() => { const unsubscribe = auth().onAuthStateChanged(firebaseUserResult => { firebaseUserResult && firebaseUserResult.emailVerified ? setUserAuth(true) : setUserAuth(false) }) return unsubscribe })