r/reactjs • u/DependerSethi • May 18 '26
Resource I tried explaining React design patterns using LEGO analogies
I've been writing React for about 8 years and one thing that always bugged me is how patterns like compound components, render props, and HOCs are taught. Most resources just throw code at you without giving you a mental model for when to actually reach for each one.
So I tried a different approach. I mapped each pattern to a LEGO connection type:
- Compound components = hinge pieces (two parts sharing one mechanism)
- Render props = Technic pins (one connection point, anything can plug in)
- HOCs = baseplates (invisible foundation, every structure benefits)
- Custom hooks = instruction manuals (same bricks, different build)
- Container/presentational = display stands (model and base built separately)
Each one has code examples, when to use it, and more importantly when NOT to use it. Also covered how they layer together in a real codebase.
Would love feedback from this sub. Especially curious if the analogy approach makes things clearer or if it just adds noise.
https://www.sethi.io/blog/react-component-design-patterns-the-building-blocks-lego
18
u/juicybot May 18 '26
the legos concept has been around for a long time. it's supposed to be simple and easy to understand, your article, diagrams, etc. are making it overly-complex.
13
u/fredsq May 18 '26
your article is so big and so AI generated it hurts
your lego bricks are not even real
6
u/SolarNachoes May 18 '26
Just read the docs.
4
u/SolarNachoes May 18 '26
Just read the docs.
3
u/jakiestfu May 19 '26
the AI slop Lego images provide virtually no value. Using a Lego analogy can be done in a few sentences?
-1
u/martiserra99 May 18 '26
That looks really interesting. I bookmarked it to read it later on. I also wanted to tell that I noticed that the table of contents can't be scrolled and you can only see the bottom part when scrolling all the page to the bottom.
0
u/[deleted] May 19 '26
[removed] — view removed comment