I would like to understand why the following code would trigger this error?
TypeError unsubscribe is not a function
It doesn't have such error when i used .onSnapshot()
function instead of get()
.
Thanks
useEffect(() => {
const unsubscribe = database
.collection("Maps")
.doc(id)
.collection("Entries")
.get()
.then(
data => {
data.forEach(doc => {
console.log(doc.id, " => ", doc.data());
});
setLoading(false);
},
err => {
setError(err);
console.log(err);
}
);
return () => unsubscribe();
}, [id]);