When I console.log(docSnap) I'm getting a firebase error, see in the below image. I have tried all the solutions but none of them worked.
useEffect(() => {
if (folderId === null) {
dispatch({
type: "UPDATE_FOLDER",
payload: { folder: ROOT_FOLDER }
})
}
// otherwise fetch from database
const getdocSnap = async () => {
const docRef = doc(db, "folders", folderId);
return await getDoc(docRef);
}
const docSnap = getdocSnap();
console.log(docSnap);
if (docSnap.exists()) {
dispatch({
type: "UPDATE_FOLDER",
payload: { folder: { id: docSnap.id, ...docSnap.data() } }
})
} else {
console.log("No such document!");
dispatch({
type: "UPDATE_FOLDER",
payload: { folder: ROOT_FOLDER }
})
}
}, [folderId])

console.log(db, folderId)in that function and share a screenshot of the output?