---
title: "Discussion on \"How Containment in React Can Improve Your Code\" | Hashnode"
description: "Discussion on \"How Containment in React Can Improve Your Code\". Component composition is undoubtedly where React shines. Being able to freely compose larger views from smaller, flexible building blocks is great. But you have to be careful because it's easy to get it wrong (or at least suboptimal).\nIn this article..."
url: "https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How Containment in React Can Improve Your Code](https://blog.tomaszgil.me/how-containment-in-react-can-improve-your-code?utm_source=hashnode&utm_medium=feed)

Component composition is undoubtedly where React shines. Being able to freely compose larger views from smaller, flexible building blocks is great. But you have to be careful because it's easy to get it wrong (or at least suboptimal). In this article...

Sep 27, 2021 · 4 min read · blog.tomaszgil.me  
Updated Sep 30, 2021  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#components](https://hashnode.com/tag/components)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Tomasz Gil](https://hashnode.com/@tomaszgil)

@tomaszgil · Poznań, Poland

  
[View profile](https://hashnode.com/@tomaszgil)

Senior Software Engineer

I help product teams build quality software and lead engineering efforts. Currently working at OpenSpace as a Senior Software Engineer.

## Responses 3

Markdown supported · ⌘↵ to post

[Gabriel Alves Cunha](https://hashnode.com/@Biel)

[Sep 30, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/6155be3e28ed304eb1d7f5fc)

Man, thanks so much for sharing that! ☺️ I have that all over my code base and it always smelled bad but I could never think of some way to fix it. Very well written, btw. Thank you ❤️

[Sep 30, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/6155be3e28ed304eb1d7f5fc#reply-615604d128ed304eb1d7fedb)

Thanks [Gabriel Alves Cunha](https://hashnode.com/@Biel) really appreciate that! Happy to help! 🎉

[AsherCode](https://hashnode.com/@AsherCode)

[Sep 27, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/615214e5040ee872369506cb)

that's a cool trick, it blowed my mind and i consider it's very useful as a react developer. Thanks for sharing it!

[Tomasz Gil](https://hashnode.com/@tomaszgil)

[Sep 28, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/615214e5040ee872369506cb#reply-6152d8249c8bfd08f5ba67cb)

Thanks [AsherCode](https://hashnode.com/@AsherCode), awesome to hear that it's useful for you! 🎉

[Ashish maurya](https://hashnode.com/@theashishmaurya)

[Sep 27, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/6151ddc2cf735d72249a865a)

This post is an absolute gem, as a developer, I can understand how helpful it is. Thanks for sharing [Tomasz Gil](https://hashnode.com/@tomaszgil) immediately bookmarked the article.

[Tomasz Gil](https://hashnode.com/@tomaszgil)

[Sep 27, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/6151ddc2cf735d72249a865a#reply-6151e7e0cf735d72249a8728)

Oh man, [Ashish maurya](https://hashnode.com/@theashishmaurya) means the world to me! Thanks a lot. 🙌

[Ashish maurya](https://hashnode.com/@theashishmaurya)

[Sep 27, 2021](https://hashnode.com/posts/how-containment-in-react-can-improve-your-code/61516eef9b404a323969a007/comment/6151ddc2cf735d72249a865a#reply-6151ed97040ee8723695030c)

You welcome buddy keep up the good work [Tomasz Gil](https://hashnode.com/@tomaszgil)
