arunoda / react-komposer

Feed data into React components by composing containers.
MIT License
732 stars 70 forks source link

Question: How to pass data to the container (ex: change parameters of the subscription) #155

Open KyneSilverhide opened 7 years ago

KyneSilverhide commented 7 years ago

Hello,

I'm using react-komposer with Meteor. Basically, my code looks like this

const composer = ({ params }, onData) => {
  const runsSub = Meteor.subscribe('runs.view', params._id);
  const teamsSub = Meteor.subscribe('teams.list');

  if (runsSub.ready() && teamsSub.ready()) {
    const run = Runs.findOne();
    const teams = Teams.find().fetch();
    onData(null, { run: run, teams: teams });
  }
};
export default composeWithTracker(composer, Loading)(EditRun);

This works well, but let's say I want to add a third subscription that should update whenever a team (from the team subscription) is selected on screen.

const devSub = Meteor.subscribe('developers.team.list', "THE SELECTED TEAM ID");

What's the best way to achieve this?

avishaan commented 7 years ago

You need to pass the new 'params' as the prop from the parent component of the container you have shown. I think the Meteor Chef site has some examples of this