我目前的反应 - komposer设置如下:
const composer = (params, onData) => {
const subscription = Meteor.subscribe('comments');
if (subscription.ready()) {
const comments = Comments.find({approved: true }, {sort: {timestamp: -1}}).fetch();
onData(null, { comments });
}
};
export default composeWithTracker(composer, Loading)(CommentsList);

我想要的是将另一个选择器传递给我的查询查询,该查询基于此组件的道具。
所以我想象它是这样的:
const comments = Comments.find({approved: true, city: {activeCity} }, {sort: {timestamp: -1}}).fetch();

但那不起作用,我做错了什么?
答案 0 :(得分:0)
我已经设法解决了这个问题。事实证明,而不是使用this.props我应该刚刚使用道具。
这是工作代码:
const composer = (props, onData) => {
const subscription = Meteor.subscribe('comments');
if (subscription.ready()) {
const activeCity = props.activeCity;
const comments = Comments.find({approved: true, city: activeCity }, {sort: {timestamp: -1}}).fetch();
onData(null, { comments });
}
};