Whenever I subscribed to publication in my app, the data returned correctly in parent component, but empty when I do subscription in the child component. Any clue about this?
This thread exactly has the problem that i facing now.
http://stackoverflow.com/questions/40112938/meteor-subscribe-works-only-on-top-level-react-component
Updates:
- In child component, I try to put meteor.subscribe in the function right before “return Post.find().fetch()” and I able to see the data retrieved correctly. It just don’t work when i call like this in child component.
constructor(props) {
super(props);
this.state = {
subscription: {
Posts:Meteor.subscribe('Posts',props.val)
},
}
}
- I’m not sure what’s happening, but I finally got it to work like this
constructor(props) {
super(props);
this.state = {
subscription: {
Post:() => Meteor.subscribe('Posts',props.val)
},
}