Menu

Post image 1
Post image 2
1 / 2
0

I Thought I Knew React. Then I Watched It Re-render 47 Times on a Button Click.

DEV Community·Shudhanshu Raj·20 days ago
#XzJIRdxY
Reading 0:00
15s threshold

A story about chasing unnecessary renders, the tools that exposed them, and the patterns that finally made them stop. Our app had a search bar. It worked fine. It felt fine. Until a designer on the team — curious, with DevTools open — asked why the sidebar, the header, the notification badge, and a completely unrelated recommendations panel all lit up in the React DevTools highlighter every time she typed a single character into it. She wasn't filing a bug. She was just confused. I was too, until I sat down and traced it. That was the beginning of three weeks I now think of as re-render hell. Not because the app was broken — it wasn't. Performance was "fine." But once you see it, you can't unsee it: a 400-component tree thrashing on every keystroke, most of it doing absolutely nothing meaningful, all of it eating time on lower-end devices that our users in Tier-2 cities actually used. What follows is the short version of what we found, what caused it, and — more importantly — what actually fixed it.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More