I don't know how to pass 'profile' or 'auth' props to firestoreConnect() function in order to query collections or documents based on user id or some other key (my code snippet is below).
i can access both 'auth' and 'profile' objects inside my jsx code but I can't find a way to use them in firestoreConnect() function (I'm getting an error: TypeError: Cannot read property 'uid' of undefined
). if I hardcode some uid then all works fine but I can't pass it as props value.
any suggestion is highly appreciated!
export default compose(
firebaseConnect(),
firestoreConnect(props => [{ collection: 'projects', where: [['uid', '==', props.auth.uid]] }]), <<--THIS LINE DOES NOT WORK
connect((state, props) => ({
projects: state.firestore.ordered.projects,
profile: state.firebase.profile,
auth: state.firebase.auth,
}))
)(Projects);
not sure why your code isn't working (its working for me). Have you tried console logging props inside the firestoreConnect? Like this:
export default compose(
firebaseConnect(),
firestoreConnect(props => {
console.log(props)
return [
{ collection: 'projects', where: [['uid', '==', props.auth.uid]] }
]
}),
connect((state, props) => ({
projects: state.firestore.ordered.projects,
profile: state.firebase.profile,
auth: state.firebase.auth,
}))
)(Projects);
Perhaps that can get you on the right track.
Hope you solve it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With