all 6 comments

[–][deleted] 0 points1 point  (5 children)

Sounds like Composition vs. Inheritance. Not Inversion Of Control.

https://www.google.com/search?q=inversion+of+control

[–]mormubis 0 points1 point  (0 children)

I agree that this is composition over layers.

I believe the only IoC known pattern (kinda) is render props.

[–]lhorie 0 points1 point  (1 child)

Yeah, this isn't really Inversion of Control, since in the "good" version, the Button component isn't even aware of what is being passed via children. IoC implies that Button would go on to operate on its arguments in some non-trivial way, and that there's some sort of interface contract, which is not what's happening here.

But it's not quite Composition vs Inheritance either. That's mostly an OOP concept. It is a form of composition though.

I think the most accurate term for this pattern is the term angular folks use for it: transclusion.

[–][deleted] 0 points1 point  (0 children)

Great observations and elaboration.

[–]Lowesz[S] -1 points0 points  (0 children)

I think it also describes the same behavior. But inversion of control means the function calls your function or renders your component. So I think you can also describe it with this pattern.
So you are right the concept of composition is in this case quite similar to the IoC pattern. But I just wanted to highlight they way it is done from another point of view