React Re-Renders Explained: Why Your Components Keep Rendering (and How to Stop It)
Why Does My Component Keep Re-Rendering?
If you’ve ever stared at your React app wondering, “Why does this component keep re-rendering every time I blink?” Welcome to the club. Re-renders are one of the most common performance bottlenecks in React apps, especially as your project scales.
But here’s the good news: once you understand why React re-renders, you’ll know exactly how to control it.
Let’s break it down - no jargon, no guesswork!
1. How React Rendering Actually Works
React’s job is to keep your UI in sync with your state. Whenever state or props change, React re-renders that component (and possibly its children).
Here’s the simplified cycle:
That means:
2. The Real Reasons Your Components Keep Re-Rendering
Let’s uncover the biggest culprits 👇
a. State Changes in the Same Component
Any time you call setState (or useState), React re-renders that component. Even if the state value doesn’t change, React still checks.
setCount(count); // triggers a re-render anyway
Fix: Only update the state when the value actually changes.
if (newCount !== count) setCount(newCount);
b. Parent Component Re-Renders
If a parent re-renders, all its children re-render too - even if their props didn’t change.
<ChildComponent />
Fix: Use React.memo() to prevent re-rendering unchanged children:
const Child = React.memo(() => {
console.log("Rendered!");
return <div>Child</div>;
});
Now the child only re-renders when its props change.
c. Unstable Function or Object Props
When you pass inline functions or objects as props, they’re re-created every render. React sees them as new values → triggers a re-render.
Recommended by LinkedIn
<Child onClick={() => setCount(count + 1)} />
Fix: Use useCallback or useMemo to keep props stable:
const handleClick = useCallback(() => setCount(c => c + 1), []);
<Child onClick={handleClick} />
d. Context Overuse
Context re-renders every component that consumes it - even if the part of the value didn’t change.
Fix: Split your context into smaller ones, or use libraries like Zustand or Jotai for selective updates.
3. How to See What’s Re-Rendering
React DevTools (Profiler tab) is your best friend here. It highlights which components re-render, how often, and why.
Pro Tip: Install the React Developer Tools Chrome extension → open Profiler → click “Record” → interact with your app → stop → see re-renders visually.
You can also log renders manually:
console.log('Rendering <MyComponent>');
Just don’t forget to remove them later!
4. Tools to Control Re-Renders Like a Pro
Here are some modern techniques that help you control rendering:
5. Rethink What “Performance” Means
React re-renders aren’t always bad - in fact, React is designed to re-render efficiently. The real problem isn’t that it re-renders, but how much work happens during those renders.
Instead of obsessing over zero re-renders:
6. Quick Checklist: Before You Optimize
If you can answer “yes” to those, you’re already ahead of 80% of React developers.
Control, Don’t Fear Re-Renders
Re-renders aren’t React being slow - they’re React doing its job. Once you understand how state, props, and parent relationships trigger renders, you’ll see that performance tuning isn’t about tricks - it’s about clarity.
Mastering re-renders = mastering React itself. And that’s where good front-end engineers become great ones!