According to the documentation , the onAuthStateChanged() function returns
Unsubscribe function for the observer.
So you can simply:
var unsubscribe = firebase.auth().onAuthStateChanged((user) { // handle it for changes signed in, signed out, or when the user ID token changed in situations such as token expiry or password change });
And then:
unsubscribe(); to register an observer.
onAuthStateChanged is an observer that calls an observer when users are signed up, logged off, or when the token of the user ID has changed in situations such as expiration of the token or password change. therefore, the second is the best solution. every entry or change.
` let userRef = "/user/" + user.uid; await firebase .database() .ref(userRef) .once("value") .then( () => { dispatch(verifyUserSignInSuccess(userSnapshot.val())); }); } else { dispatch(verifyUserSignInFailure(USER_NOT_SIGNED_IN)); }`
which is correct for cross-checking whether it is valid or not. I don't think memory comparison is required.
source share