Why React re-renders
What actually triggers a React re-render, why it cascades to children by default, and why a re-render is not the same thing as the browser repainting pixels.
Why React re-renders
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A re-render is React calling your component function again to compute a new description of the UI. It is not the browser repainting anything on screen.
- Only three things can start a re-render: a piece of state changing, a parent component re-rendering, or the value read from a context changing.
- By default, when a component re-renders, every one of its children re-renders too, whether or not that child's own props actually changed.
- React compares the new description against the last one (via the virtual DOM and reconciliation) and only touches the real DOM where something differs, so a re-render is cheap but still not free.
- A component re-rendering ten times a second because of unrelated state elsewhere in the tree is a sign of a missing boundary, not a sign that React is slow.
- Measuring whether re-renders are actually a problem comes before trying to prevent them; most re-renders never show up as a visible slowdown.
Re-rendering is not repainting
The word “render” causes most of the confusion in this topic. In React, a render has nothing to do with pixels appearing on a screen. A render is React calling your component function again and getting back a fresh description of what the UI should look like — a tree of React elements, often written as JSX.
function Clock({ now }) {
console.log("Clock rendered");
return <p>{now.toLocaleTimeString()}</p>;
}
Every time Clock “renders,” that console.log runs and the function returns a new element tree. React then compares that tree to the one from the previous render (this is reconciliation, covered earlier in this roadmap) and figures out the minimal set of real DOM mutations needed to match it. Only that step — updating the actual DOM nodes — can lead to the browser doing layout and repaint work. A component can re-render dozens of times while the browser touches the screen zero times, because React found no differences to commit.
This distinction matters because it reframes the whole topic. The question is not “how do I stop React from calling functions,” which is cheap. The question is “when does calling those functions, or the diffing that follows, actually cost something worth caring about.”
The only three triggers
A component does not re-render for no reason, and it does not re-render just because time passes or because some unrelated part of the app changed. Exactly three things can start a re-render:
- State changes. Calling a
useStatesetter (or dispatching touseReducer) with a new value schedules a re-render of that component. - A parent re-renders. When a component’s function runs again, React re-renders every child it returns, by default, regardless of whether that child’s own props changed.
- A context value changes. Every component that calls
useContextfor a given context re-renders when the value passed to that context’sProviderchanges, even components far down the tree.
Notice that “a prop changed” is not in that list by itself. A prop can only be different because something above decided to pass something different, and that something above only ran because one of these three triggers fired on it or an ancestor.
function Parent() {
const [count, setCount] = useState(0);
return (
<div>
<button onClick={() => setCount((c) => c + 1)}>+1 ({count})</button>
<ExpensiveChild />
</div>
);
}
function ExpensiveChild() {
console.log("ExpensiveChild rendered");
return <p>I don't depend on count at all.</p>;
}
Click the button and ExpensiveChild logs on every click, even though it reads no props and no state that changed. Parent’s state changed, Parent re-rendered, and by default every child in its returned tree re-renders along with it. This cascade is the single most common source of “why is this component re-rendering” confusion, and it is working exactly as designed.
Cheap by design, not free
React’s whole architecture — the virtual DOM, the diffing algorithm, the batching of state updates — exists to make re-rendering cheap enough that this default cascade usually doesn’t matter. For the overwhelming majority of components, calling the function again and diffing the result costs a fraction of a millisecond. React was built on the bet that developer code is easier to reason about if you don’t have to manually track which parts of the tree need updating, and that the cost of recomputing descriptions you don’t end up using is worth paying for that simplicity.
But “cheap” is not “free,” and the cost scales with how much work a component’s function body does and how many children sit beneath it. A component that re-renders 60 times a second while running a genuinely heavy calculation, or that re-renders a list of thousands of rows because one unrelated input field changed somewhere above it, can turn an invisible cost into a visible stutter. The next lessons in this group — useMemo, useCallback, React.memo, and profiling with React DevTools — are all tools for finding and narrowing exactly that kind of cascade, once you can point at it. None of them matter until you understand this chapter’s model: re-renders start from state, parent cascades, or context, and they are a React-internal bookkeeping step that is separate from whatever the browser eventually paints.
What the video covers
Developer Way’s “Intro to re-renders” is the opening episode of a dedicated course on React re-renders, and it covers this lesson’s core claims directly: the three real triggers (state, parent cascade, context), and an explicit statement that a re-render is React’s internal recalculation rather than the browser painting anything. At seven minutes it moves fast and leans on live code demos rather than written explanation, so it’s best watched as a visual confirmation of the mental model above rather than the first time you encounter it. It does not spend time on measuring whether a given re-render actually costs anything, which is the judgment call the rest of this lesson group builds toward.
Where this fits
Now that you know what triggers a re-render, the next lesson covers the two hooks React gives you to avoid redoing expensive work across them: useMemo and useCallback.
Check yourself
Does a React component re-rendering mean the browser just repainted pixels on the screen?
No. A re-render is React calling the component function again to produce a new virtual DOM description. React then diffs that description against the previous one and only commits the specific DOM changes it finds, and the browser only repaints if something actually changed on screen.
What are the three things that can cause a component to re-render?
Its own state changing, its parent re-rendering, or a context value it reads changing. Props changing on their own do not trigger a re-render directly; a prop can only change because the parent that passed it re-rendered.
If a parent component re-renders, do all of its children re-render too, even if none of their props changed?
Yes, by default. React re-renders every child in the subtree whenever the parent re-renders, regardless of whether that specific child's props actually changed, unless something like memoization intervenes.
Why is it misleading to call every re-render a performance problem?
Because re-rendering a component is usually fast, and React still only writes to the real DOM where the output actually differs. Treating every re-render as a bug leads to premature optimization; the better approach is to measure first and only intervene where a re-render is both frequent and actually expensive.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.