my code:
ListComponent :
renderList() {
return this.state.deals.map((deal) => (
<DealItem key={deal._id} deal={deal} />
));
}
DealItem :
componentDidMount() {
this.dealItemTracker = Tracker.autorun(() => {
const handle = Meteor.subscribe('product.getName', this.props.deal.productId);
const product = Products.find().fetch()[0];
console.log(this.props.deal.productId);
console.log(product);
Meteor.subscribe('userData.getName', this.props.deal.orderBy);
const user = Meteor.users.find().fetch()[0];
this.setState({
product: product,
orderBy: user.profile.firstname
});
});
}
componentWillUnmount() {
this.dealItemTracker.stop();
console.log("Component unmount");
}