The layout of my data in Firestore:
User documents contain an array of id references to chat documents.
Ex:
collections
/users
'CQATa3f3d2XmBskmmt8hmCJhzcJ2'
name: '...'
email: '...'
chats: ["RuUKEwsGtR9QylicdgJW", "JlzcIfkZ1KzeXClhJvOE"]
/chats
...
For the current user, I want to get the chat object associated with each element in its chat array. This data should go to firestore.ordered so I can supply it to a FlatList, but firestore.ordered.chats is always undefined, even though firestore.data.chats has the correct data.
I'm not sure if this is an issue having to do with the order in which I call connect and firestoreConnect or how I am using populates, or something else.
... Component ...
const populates = [
{ child: 'chats', root: 'chats' }
]
const mapStateToProps = (state, props) => {
return {
auth: state.firebase.auth,
user: populate(state.firestore, 'users', populates),
chats: state.firestore.ordered.chats,
}
}
// ---- TEST ----
export default compose(
connect(mapStateToProps, mapDispatchToProps),
firestoreConnect((props) => {
return [ { collection: 'users', doc: props.auth.uid, populates } ]
}),
)(Main)
Result of logging state inside of mapStateToProps: