0

我从过去 2 天开始就被这个问题所困扰,现在我决定在这里发布它。我不知道出了什么问题以及在哪里。一切似乎都很好,并且在我使用 where 查询的屏幕上工作,但是当我移动到另一个屏幕并尝试从应用程序注销时,会弹出此错误。

反应本机firebaseconnect错误

这是我的 Firestore 集合结构:

反应本机firebaseconnect错误

现在这是我为实现这一目标而编写的代码:

    //console.log(state.firestore.data['otherSquads'])
    return {
        auth: state.firebase.auth,
        totalSquads: state.firestore.ordered.squad,
        currUser: state.firestore.data['currentUser']
    }
}

export default compose(
    connect(mapStateToProps),
    firestoreConnect(props => {
        const userid = props.auth.uid;
        return [
            {
                collection: 'squad', 
                where: [['squadMembers', 'array-contains', userid]],
                orderBy: ['createdAt', 'desc']
            },
            {
                collection: 'users',
                doc: userid,
                storeAs: 'currentUser'
            }
        ]
    })
)(SquadScreen);
4

1 回答 1

0

当用户注销时,userid此代码中的参数变为null

where: [['squadMembers', 'array-contains', userid]],

正如错误消息所说,您无法传递nullwhereEqualTo操作。它仅在array-contains操作中有效。

解决方案是在您注销用户之前分离查询侦听器。我自己从来没有这样做过redux-firebase,但这种detachListener方法似乎很有希望。

于 2019-11-20T15:18:34.760 回答