⚛️ Writing Better React Components — What I’ve Learned One thing that really changed the way I write React was realizing that a component doesn’t have to do everything. Back in the day, I used to build these giant components — they handled state, fetched data, rendered UI, and managed every little event. And of course... they quickly turned into chaos 😅 Hard to test Hard to reuse Easy to break Over time, I started focusing more on composition — breaking things down into smaller, more focused pieces. Here are a few things that made a big difference for me 👇 ✅ Keep responsibilities clear. Let each component do one job well — UI, logic, or data, but not all three. ✅ Think in lego blocks. A small generic piece can power a bunch of different components. ✅ Lift state only when it makes sense. Sometimes you don’t need that useState here — maybe it belongs one level up. ✅ Reuse logic with custom hooks. useFetch, useForm, useModal — anything that helps keep the UI clean and logic separate. (Check the example in the image bellow) - Card just handles layout and style. - UserCard adds data and meaning. - Nice and simple — and way easier to maintain. 💡 These small mindset shifts made my React code cleaner, more predictable, and honestly... a lot more fun to write. #development #frontend #javascript #react #programming #dev
Great way to implement ! To improve more we can have conditional render on children inside card and have some default fields / values required for card or even basic stylings. Sometime we need not want to pass children and just render the card .
Good post! Very nice 👏
Good post! Very nice
Nice post! 👍 Thanks for sharing!