I'm trying to see if any users are already enrolled in a class. I'm trying to set the state classesArray into an array of the classes that they are already enrolled in. For some reason, it performs the action inside if(user) even though user is undefined.
const Button = ({currentPage, currentCourse, user}) =>
{
const [classesArray, setArray] = useState([]);
useEffect(()=>{
if (user)
{
let tempArray = db.collection('users').doc(user.id).classes;
console.log(tempArray)
}
})