Course map
Stage 1: Foundation
Stage 2: Intermediate
Stage 3: Advanced
Stage 4: Routing and Application Architecture
Stage 5: Specialization (pick ONE)

Part 01 / Topic 7 of 8

Why React re-renders

A render is React calling your component function and using whatever JSX it returns. A re-render is React calling that same function again. That is the whole idea - nothing is hidden, nothing is magic. examples/04_render_counter.jsx proves it with a counter, deliberately without useState (Part 3's job):

let callCount = 0;

export function Clock({ tick }) {
  callCount += 1;
  return (
    <p>
      Render #{callCount}: tick {tick}
    </p>
  );
}

Rendering <Clock tick={1} /> and then asking Testing Library to re-render <Clock tick={2} /> in the same spot - really run, React 19.3.1 + Testing Library 16.3.3 - gives:

Render #1: tick 1
Render #2: tick 2
Render #3: tick 3

(three renders because the test re-renders twice more after the first). Every single one of those was the Clock function running from the top again, in full - not some part of it, not a diff being applied to the old call.

This file is demonstration code, not something to copy into a real project: mutating a variable declared outside the component during render is a genuine side effect, and this course's linter agrees. Running oxlint (bundled with the Vite template, version 1.96.0 at the time of writing) over this exact file gives:

warning react(globals): Cannot reassign variables declared outside of the component/hook
help: Variable `callCount` is declared outside of the component/hook. Reassigning this
value during render is a side effect which can cause unpredictable behavior. If this
variable is used in rendering, use useState instead.

That warning is correct, and it is exactly the gap Part 3's useState fills - "a component remembers a number between renders" needs a tool React is aware of, not a plain module variable. Section 1's "component re-describes itself" idea and this section's "re-render is just calling the function again" idea are the same fact, stated two ways; keep both, because Part 3 onward builds directly on this one.

Done here? The practice set for Part 1 — including the solutions — is on the part page.

Search the guide