【问题标题】:React Native Error : [Unhandled promise rejection : FirebaseError: Expected type 'Da', but it was: a custom Ua object]React Native 错误:[未处理的承诺拒绝:FirebaseError:预期类型“Da”,但它是:自定义 Ua 对象]
【发布时间】:2022-02-21 08:30:19
【问题描述】:

我正在使用 react native 来克隆火种。

用户权限刷卡时会出现上述错误。

我正在使用 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
          );
        }
      }
    );

【问题讨论】:

    标签: node.js reactjs firebase react-native


    【解决方案1】:

    检查上面的代码

    const loggedInProfile = await (
          await getDoc(doc(db, "users", user.uid))
        ).data();
    

    这段代码 sn-p 对我有用。 并检查您是否使用 getDoc's' 而不是 getDoc

    希望对您有所帮助

    【讨论】:

    • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2022-01-15
    • 2017-10-09
    • 2018-06-16
    • 1970-01-01
    • 2022-01-02
    • 2022-01-05
    • 1970-01-01
    • 2022-07-05
    • 2021-03-28
    相关资源
    最近更新 更多