Hey guys,
something is confusing me when using React-Native-Meteor with publishComposite. Assuming I have the following publish function:
publishComposite('allUserData', {
find() {
return User.find({_id: this.userId}, {fields: {'details': 1, 'username':1}});
},
children: [
{
find() {
return Friends.find({userId2: this.userId});
},
children: [
find(friendDoc) {
return User.find({_id: friendDoc.userId1});
}
]
}
]
});
Within my React component, I do something like this
Friends.find().fetch().map((friendDoc) => <FriendItem userDoc={User.findOne(friendDoc.userId1)}/>);
Now, on some reloads, I run into trouble. My app tells me, that userDoc
is null. So the data of User.find({_id: friendDoc.user1});
seems not to be added at the same time like the data of Friends.find({userId2: this.userId});
. Since React-Native-Meteor does not use the “real” Livedata/Minimongo system of Meteor, I’m wondering if this behavior is the same in a normal Meteor application?
PS: I know that there is no createContainer function in my code to provide reactivity. In my real project I’m using it, it’s just to show you how I run into that null object (because I’m working with data from another collection which is published by the same publication but not available at the same time).