I want to use a variable value based on conditional statement of onAuthStateChange of Firebase Authentication but it seems the variable value is not assigned.
let isLoggedIn
onAuthStateChanged(auth, (user) => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/firebase.User
console.log(true)
isLoggedIn = true
} else {
// User is signed out
console.log(false)
isLoggedIn = false
}
});
console.log(isLoggedIn)
but the console result is:
undefined
true //I already logged in
how do I assign value of a variable outside onAuthStateChanged
?