Why Your React Component Re-renders and How to Trace It

A component re-renders when its state changes or a parent re-renders. Learn the causes and trace them with the React DevTools Profiler.

5 min read

A React component re-renders when its state changes or when its parent re-renders. Tracing a re-render means finding which update caused it. The React DevTools Profiler shows exactly which components rendered, so you can match a re-render to its cause.

Two reasons a component renders

A component renders on its initial render, and it re-renders when state updates. The update can come from the component itself or from an ancestor. A parent re-render cascades down to its children, which is the part beginners often find surprising.

App.jsxApp.jsx
import { useState } from "react";
 
function Counter() {
  const [count, setCount] = useState(0);
  return <button onClick={() => setCount(count + 1)}>{count}</button>;
}

Clicking the button calls setCount, which triggers a re-render of Counter. React also re-renders every child of Counter, because the child output might depend on the new state. That default is intentional, and memoization is the opt-out when a subtree is slow.

What re-rendering actually does

Rendering is React calling your component function. React compares the returned JSX with the previous result and only commits the differences to the DOM.

A re-render is not a full page reload. React reuses DOM nodes that did not change. This is why typing in an input does not lose its text when a sibling re-renders. The render and commit guide walks through the trigger, render, and commit steps in detail.

Trace a re-render with the Profiler

Open React DevTools and select the Profiler tab. Click record, interact with the page, then stop recording. The flamegraph lists every component that rendered and how long each one took.

The Components tab has a Highlight updates setting. Turn it on and React outlines components with a flashing border as they render, so you can watch a re-render spread through the tree in real time.

The DevTools guide covers installing and opening these tools.

Common causes of extra renders

Most unnecessary re-renders come from new values created during render.

  • A new object or array literal passed as a prop is a fresh value every render.
  • A new inline function passed as a prop does the same.
  • A context value change re-renders every component that reads it.

None of these are automatically bugs. Re-rendering is cheap, and the fix is often to measure first. Only optimize a render that the Profiler shows is actually hurting.

A re-render alone is not a problem. The problem is a slow re-render, so let the Profiler point you to the component that takes the time.

What to learn next

When a re-render is genuinely expensive, the performance guide shows memoization and profiling techniques that skip work without guessing.

Rune AI

Rune AI

Key Insights

  • A component renders on mount and re-renders on state updates.
  • A parent re-render also re-renders its children.
  • Rendering is React calling the component function.
  • React only commits DOM changes when the output differs.
  • Use the Profiler to trace re-renders before optimizing.
RunePowered by Rune AI

Frequently Asked Questions

Why does my React component re-render?

It re-renders when its own state changes, when a parent re-renders, or when a context value it reads changes. The initial render is separate and happens once.

Is a re-render the same as a page reload?

No. A re-render is React calling the component again and updating only the DOM nodes that changed. It does not reload the page.

How do I see which components re-render?

Open React DevTools and use the Profiler tab to record an interaction. The Components tab also has a Highlight updates option that outlines components as they render.

Conclusion

A component re-renders when its state changes or a parent re-renders. Trace the cause with the React DevTools Profiler, and only optimize a render that actually hurts after you have measured it.