簡體   English   中英

React Native 錯誤:[未處理的 promise 拒絕:FirebaseError:預期類型 'Da',但它是:自定義 Ua 對象]

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM