【发布时间】:2018-01-07 21:10:22
【问题描述】:
如何使 PostList 类组件从订阅中呈现,我真的没有获得 withtracker 功能,我用谷歌搜索并找到了不同的版本,但我无法弄清楚它是否可以工作,我做错了什么以及我应该怎么做是吗?我确实重新阅读了文档,但没有太大帮助,请解释一下。
react-meteor-data 包
this is my mongo db.posts.find()
{ " _id " : ".." , " data " :{ " title " : " s " , " description " : "a" }, " userid " : "..." , " createdat ":131231}
my publish Meteor.publish("postlist",function(){
return Posts.find({});
})
my react component
export default class PostList extends React.Component{
render(){
return{
}
}
}
withTracker((props) => {
const handle = Meteor.subscribe('postlist');
return {
loading: !handle.ready(),
posts: Posts.find().fetch()
}
}, PostList)
【问题讨论】: