
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