'can't run setDoc inside onSnapshot listener with react native and firebase
i am building app with expo.io react native and firebase / firestore. i am trying to setDoc inside onSnapshot which giving me error i can't understand
const requestListener = onSnapshot(
// @ts-ignore
doc(db, "PendingRequets", currentWinchDriverId),
(doc) => {
if (!doc.exists()) {
console.log("driver ");
// @ts-ignore
setDoc(doc(db, "PendingRequets", currentWinchDriverId), {
name: "hello world",
});
}
}
);
and it fires this error
ypeError: doc is not a function. (In 'doc(_firebase.db, "PendingRequets", currentWinchDriverId)', 'doc' is an instance of Vh)
please note this code is running inside useEffect
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
