Ryan Florence - Compound Components
Video Statistics and Information
Channel: Phoenix ReactJS
Views: 35,392
Rating: undefined out of 5
Keywords:
Id: hEGg-3pIHlE
Channel Id: undefined
Length: 43min 19sec (2599 seconds)
Published: Sat Apr 01 2017
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
Am I wrong to assume compound components means readjusting the child component's props through cloning rather than adjusting the child component itself? The latter seems more react-like and compounding components seem a bit more complex than using context despite hints of context's deprecation.
Compounding's intent seems to be allowing smaller components to be untouched therefore avoid bloating it with unnecessary amount of conditionals and leave modifications to the parent. This would mean the smaller component,
<Tab />
, in this case to be more reusable without reimplementing it specifically for<TabList />
though it seems less likely<Tab />
itself would be used outside of<TabList />
which gave me the impression it doesn't improve<Tab />
's reuse.If I am on the right track would anyone mind giving an example where compound components would excel rather than use of HOC/context?
This goes against the declarative composition that you should follow in react.
Don't clone the elements, create another component that is going to take care of rendering the right sub components.
I'm not surprised that Ryan is presenting this technique. I've seen many things in React Router that did not really followed the react way of things.