I published data on the server side, but when I subscribe the data, I first got empty and then real data. How can I subscribe the real data at first?
class BlogItem extends Component{
render(){
console.log(this.props.posts);
return(
this.props.posts.map(post =>{
return(
<li className="list-group-item" key={post._id}>
title:{post.title}
</li>
);
})
);
};
}
export default createContainer((props) => {
Meteor.subscribe('posts');
return { posts: Posts.find({}).fetch() };
}, BlogItem);
publish on server:
Meteor.startup(() => {
Meteor.publish('posts', function() {
return Posts.find({});
});
});