import React from 'react';
import { useState, useEffect, useContext } from 'react';
import { auth } from '../../utils/firebase';
import AuthContext from '../../contexts/AuthContext'
//Components
import Navbar from './Navbar';
function Dashboard() {
const [email, setEmail] = useState("");
const [uid, setUID] = useState();
useEffect(() => {
console.log(auth.currentUser["email"]);
setEmail(auth.currentUser["email"]);
console.log(email);
}, []);
return (
<div>
<Navbar />
<h1>Dashboard</h1>
</div>
);
}
export default Dashboard;
Hello, I am trying to create a program with react where i log in the user with firebase. However, when trying to get the email and uid from the user, I am able to display the data auth.currentUser["email"] when i do console.log(auth.currentUser["email"]) but when i try to set the state setEmail(auth.currentUser["email"]) and console.log(email) console.log doesn't display anything and I won't understand why?? And i need to access the email to get further data from the user so thank you in advance