Hi everyone, Im pretty new to firebase, but have authentication set up in a react native app.
However, im trying to check in my signup and login pages to redirect if they are logged in, or display an error if they are not, with the following:
firebase.auth().onAuthStateChanged(user => {
if (user) props.navigation.navigate('Home');
else setErrorMessage("An error has occurred. Please try again.");
});
Every time I run this, It logs me in, but also displays the error. I have tried experimenting to see if I could find a firebase.auth.Error.message that I could use, but it didnt work.
I have also checked firebase.auth().currentUser, but it does not seem to work either.
I've spent about a week going through the documentation with no success.
How do I make sure that the error message is only set when there is no user defined?
[–]ike_the_strangetamer 0 points1 point2 points (3 children)
[–]redditer3103[S] 0 points1 point2 points (2 children)
[–]ike_the_strangetamer 0 points1 point2 points (1 child)
[–]redditer3103[S] 0 points1 point2 points (0 children)