How do you get the data from the document using document id? I am trying to get the current signed in user details from the document using the id, but i am not able to retrive the details.
import{useState} from 'react';
import { getAuth, onAuthStateChanged } from "firebase/auth";
import { doc } from "firebase/firestore";
import { db } from '../../firebase';
const Single = () => {
const [userId, setUserId] = useState("");
const auth = getAuth();
onAuthStateChanged(auth, (user) => {
if (user) {
const uid = user.uid;
setUserId(uid)
} else {
}
});
const docData = db.collection("users").doc(userId).get();
setUserData(docData)
console.log(docData)
}