React Re-Renders Explained: Why Your Components Keep Rendering (and How to Stop It)
Photo by Fili Santillán on Unsplash

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:

  1. You update state → React re-renders the component.
  2. React compares the new virtual DOM to the old one.
  3. It updates only what’s changed on the screen.

That means:

  • Re-renders aren’t always bad - they’re how React works.
  • But unnecessary re-renders can slow your app and cause jank.

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.

<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:

  • React.memo() → Prevents re-render when props don’t change → export default React.memo(Component)
  • useMemo() → Caches computed values → const value = useMemo(() => heavyCalc(data), [data])
  • useCallback() → Caches functions → const fn = useCallback(() => doSomething(), [])
  • useTransition() → Defers expensive state updates → Great for smooth UIs
  • useDeferredValue() → Defers a value until rendering is done → Useful for search filters

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:

  • Focus on reducing expensive operations (loops, data parsing, DOM mutations).
  • Profile first - then optimize.
  • Use tools like React Profiler, Lighthouse, or Chrome Performance Panel.

6. Quick Checklist: Before You Optimize

  • Am I updating the state unnecessarily?
  • Is a parent re-rendering too often?
  • Am I passing unstable props (functions/objects)?
  • Can I memoize or split components?
  • Have I actually measured the performance issue?

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!

To view or add a comment, sign in

More articles by John Kali

Others also viewed

Explore content categories