Is it possible to pass props to React Komposer


#1

up vote
0
down vote
favorite
I currently have my react-komposer set up like this:

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);

What I would like is to pass another selector to my find query which is based on the props of this component.

So I imagine it something like this:

const comments =  Comments.find({approved: true, city: {activeCity} }, {sort: {timestamp: -1}}).fetch();

#2

I already managed to find the answer after reading the documentation of react-komposer again.

Turns this is the way to do it:

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 });
  }
};