Got a question: Just came back to one of my old Expo apps that would sign people in even when the app is refreshed using the user state. For some reason, it doesn't work anymore. The code is supposed to read the user object, which is usually not null, and check if the email is verified, which will then sign in the user without the user trying to log in. The problem I found is that the user object is null, which doesn't automatically sign in the user. Really, the first line that doesn't work is the start of the unsubscribe variable. Can someone help with what I got for automatically signing people in. Note: I am using the Firebase package to automate this
Code:
useEffect(() => {
setTheme("dark");
const unsubscribe = auth.onAuthStateChanged((user) => {
console.log(user);
if (user !== null) {
if (user.emailVerified) {
console.log(user);
console.log(user.emailVerified);
navigation.replace("Home");
}
}
});
return unsubscribe;
}, []);
from How to automate sign in Expo React Native app
No comments:
Post a Comment