Is it a good idea to pass Meteor.userId() as a property to a component?

I have an hierarchy of components (about 4 levels deep), that all require the current Meteor.userId(). Is it a good idea to set the userId in the top component and then pass it to the subsequent children through the properties? or should I check for the Meteor.userId() in each component? My gut feeling tells me the first approach is better, but still wanted to make sure.

Thanks
Sudheer

Your gut feeling is correct.

  1. You may want to use your components for arbitrary users (not just the logged in user) at a later point in your app development and, if the userId comes through the props, there would be no refactoring required.

  2. You want your components as “dumb” as possible, with no data sneaking in through the side door. Keeps things predictable.

1 Like

thanks @babrahams. That helped a lot.