2016-12-02 7 views
0

私は現在、私の反応-komposerは次のように設定している:私が望む何React 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

私はすでにこの問題を解決することができました。代わりにthis.propsを使用する代わりに、私は代わりに小道具を使用していたはずです。

これは、作業コードです:

const composer = (props, onData) => { 
 
    const subscription = Meteor.subscribe('comments'); 
 
    if (subscription.ready()) { 
 
    \t const activeCity = props.activeCity; 
 
    const comments = Comments.find({approved: true, city: activeCity }, {sort: {timestamp: -1}}).fetch(); 
 
    onData(null, { comments }); 
 
    } 
 
};

関連する問題