I am stuck with this issue from last 2 days and now i decided to post it in here. i don't know what is going wrong and where. everything seems fine and working in screen where i used the where query but when i moved to another screen and try to signout from the app this error pops out.
And here is my firestore collection structure :
Now here is my code which i wrote to acheive this :
//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);
When the user signs out, your userid
parameter in this code becomes null
:
where: [['squadMembers', 'array-contains', userid]],
As the error message says, you cannot pass null
to whereEqualTo
operations. It is only valid in array-contains
operations.
The solution is to detach the query listener before you sign the user out. I've never done this with redux-firebase
myself, but this detachListener
method seems promising.