如何使用来自meteor订阅的数据

时间:2017-02-22 21:05:03

标签: reactjs meteor subscription

我在Meteor应用的用户集合中向根添加了额外字段,无法通过反应访问它们。 这是出版物:

if (Meteor.isServer) {
   // This code only runs on the server

 Meteor.publish('currentUserInfo', () => {
     if (!this.userId) {
         return this.ready();
     }

     return Meteor.users.findOne({_id: this.userId});
 }); }

这是订阅:

export default createContainer(()=>{
    Meteor.subscribe('currentUserInfo');

    return {
        currentUser: ???,

如何通过道具传递订阅数据?

1 个答案:

答案 0 :(得分:1)

Meteor.user()

Meteor.users.findOne(Meteor.userId())