Reactjs firestoreConnect查询-只能对null执行相等比较(通过whereEqualTo)
我被过去两天的问题缠住了,现在我决定把它贴在这里。我不知道哪里出了问题,哪里出了问题。在我使用where查询的屏幕上,一切看起来都很好,但当我移动到另一个屏幕并尝试从应用程序注销时,这个错误就会弹出 以下是我的firestore收藏结构: 现在,这是我为实现这一目标而编写的代码:Reactjs firestoreConnect查询-只能对null执行相等比较(通过whereEqualTo),reactjs,firebase,react-native,google-cloud-firestore,react-redux-firebase,Reactjs,Firebase,React Native,Google Cloud Firestore,React Redux Firebase,我被过去两天的问题缠住了,现在我决定把它贴在这里。我不知道哪里出了问题,哪里出了问题。在我使用where查询的屏幕上,一切看起来都很好,但当我移动到另一个屏幕并尝试从应用程序注销时,这个错误就会弹出 以下是我的firestore收藏结构: 现在,这是我为实现这一目标而编写的代码: //console.log(state.firestore.data['otherSquads']) return { auth: state.firebase.auth,
//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);
当用户注销时,此代码中的
userid
参数变为null
:
where: [['squadMembers', 'array-contains', userid]],
正如错误消息所说,您不能将null
传递到whereEqualTo
操作。它仅在包含操作的数组中有效
解决方案是在用户注销之前分离查询侦听器。我从来没有用redux firebase
自己做过这件事,但这似乎很有希望