Last active
August 20, 2023 18:47
-
-
Save mrcflorian/99d7b46ae8323f103213e331c1f1d7ff to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
import { firebase } from '../../firebase/config' | |
... | |
export default function LoginScreen({navigation}) { | |
... | |
const onLoginPress = () => { | |
firebase | |
.auth() | |
.signInWithEmailAndPassword(email, password) | |
.then((response) => { | |
const uid = response.user.uid | |
const usersRef = firebase.firestore().collection('users') | |
usersRef | |
.doc(uid) | |
.get() | |
.then(firestoreDocument => { | |
if (!firestoreDocument.exists) { | |
alert("User does not exist anymore.") | |
return; | |
} | |
const user = firestoreDocument.data() | |
navigation.navigate('Home', {user}) | |
}) | |
.catch(error => { | |
alert(error) | |
}); | |
}) | |
.catch(error => { | |
alert(error) | |
}) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@mrcflorian You're not supposed to manually navigate when conditionally rendering screens. See here: https://reactnavigation.org/docs/auth-flow/#dont-manually-navigate-when-conditionally-rendering-screens.
Suggested that this be removed:
navigation.navigate('Home', {user})
(line 27)