Are you try to get data from the database? You would still have to use pub/sub. Sounds like you are looking for createContainer. So I guess that is what you meant by container based. Also there is an alternative react-komposer.
@townmulti Basically, with the smart/dumb component model I can’t get the user information on a per post basis because all of that data is supposed to be fetched by the “smart” parent component.
So I’m curious about how I could go about getting that data and combining it with the post so that the dumb component doesn’t really have to do any work.
Yes, you should be able to get any data you want. You just have to publish it, subscribe and return it from the container. For example, using createContainer:
The allPosts will load into this.props on PostPage.
So to get the user data per post, you may have to already have that data within the Post document as when you save the post.
let postToSave = {
poster_hsid: this.userId,
poster_username: username,
poster_photo: photo,
post_date: new Date(),
post_text: status,
};
Post.insert(postToSave);
I found that easier than having to join collections using one of the join packages. You can also embed an array objects (such as comments) within the Post collection. But the issue I have with that is that if the user updates their info, then the Post document would be out of date. So newly, I’m learning Apollo because it’s easier to get all that data in one query without duplicating it throughout collections.
Thanks for the thorough response! I try to avoid duplicating data and having to perform updates in multiple places should that data change.
Maybe Apollo is the only answer right now, but I don’t think so. I’ve done this with Blaze and I think for React it’s just a matter of finding the pattern.