vendredi 8 juillet 2016

What is the idomatic way to use props in component composing in reactjs

Dear architects/design experts,

I'm using Alt Js to inject stores and actions to react native components. In this case some stored properties are not using in entire component tree, but only by some components which are in very deeper level.

For Ex: (Please refer with image) I have composed component X using Y and Z components. And injected an alt store called P to component X and passing it to component Z through component Y as a prop. In this case the P store is not using by component Y, but had to pass as a prop to Y because it needs to component Z

I feel like the prop requirement of component Z ruins the usage places of component Y because of that prop is really not using by Y in it self, just passing to Z. What is the idiomatic way to inject alt stores and pass props to child components without messing the code. Is there a way to pass props, inject alt stores to one specific place and use in every component without passing through entire component tree.

(Sorry for the bad illustration) ;) Regards,

Component composing layout

Aucun commentaire:

Enregistrer un commentaire