![](/img/trans.png)
[英][Unhandled promise rejection: FirebaseError: Function addDoc() called with invalid data. Unsupported field value: a custom Class object
[英]React Native Error : [Unhandled promise rejection : FirebaseError: Expected type 'Da', but it was: a custom Ua object]
我正在使用本機反應來制作火種克隆。
用戶右刷卡時出現上述錯誤。
我正在使用 Firebase 來存儲數據。
這是問題所在的代碼,但不能一個,請幫助。
代碼:
// check if the user swiped on you...
getDoc(doc(db, "users", userSwiped.id, "matches", user.uid)).then(
(documentSnapshot) => {
console.log(documentSnapshot);
if (documentSnapshot.exists()) {
// user has matched with you before you had matched with them.
// Create a MATCH
console.log(`hooray you MATCHED with ${userSwiped.displayName}`);
setDoc(
doc(db, "users", user.uid, "matches", userSwiped.id),
userSwiped
);
// storing matched users data separately
setDoc(doc(db, "matched", generateId(user.uid, userSwiped.id)), {
user: {
[user.uid]: loggedInUserProfile,
[userSwiped.id]: userSwiped
},
usersMatched: [user.uid, userSwiped.id],
timestamp: serverTimestamp()
});
navigation.navigate("Match", {
loggedInUserProfile,
userSwiped
});
}
else {
// user has swiped as first interaction between two or did not get swiped.
console.log(`you swiped on ${userSwiped.displayName}`);
setDoc(
doc(db, "users", user.uid, "matches", userSwiped.id),
userSwiped
);
}
}
);
檢查上面的代碼
const loggedInProfile = await (
await getDoc(doc(db, "users", user.uid))
).data();
此代碼片段對我有用。 並檢查您是否使用 getDoc's' 而不是 getDoc
我希望你會發現這有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.