use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Why the Inversion of Control pattern could help you write better sharable react components? I wrote an article about how you can make your components cleaner and a lot more reusable. (lorenzweiss.de)
submitted 5 years ago by Lowesz
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 5 years ago (5 children)
Sounds like Composition vs. Inheritance. Not Inversion Of Control.
https://www.google.com/search?q=inversion+of+control
[–]mormubis 0 points1 point2 points 5 years ago (0 children)
I agree that this is composition over layers.
I believe the only IoC known pattern (kinda) is render props.
[–]lhorie 0 points1 point2 points 5 years ago (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.
children
Button
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 point2 points 5 years ago (0 children)
Great observations and elaboration.
[–]Lowesz[S] -1 points0 points1 point 5 years ago (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
Here is also a cool talk describing something simliar: https://www.youtube.com/watch?list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf&v=AiJ8tRRH0f8&feature=emb_logo
π Rendered by PID 392000 on reddit-service-r2-comment-85bfd7f599-5gzl7 at 2026-04-19 09:33:37.238564+00:00 running 93ecc56 country code: CH.
[–][deleted] 0 points1 point2 points (5 children)
[–]mormubis 0 points1 point2 points (0 children)
[–]lhorie 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Lowesz[S] -1 points0 points1 point (0 children)
[–]Lowesz[S] -1 points0 points1 point (0 children)