Rendering and scheduling

What triggers a render, and how React decides what to do first.

Builds on Fiber, State.

In Part 2 you built a work loop that walks fibers one at a time, can stop between them, and only touches the DOM in a separate commit step. In Part 3 you used real React on top of a machine like that without thinking much about when it runs. This chapter opens the hood again. When exactly does React call your component? Why does a component whose props never changed render anyway? And when two updates arrive at once, how does React decide which one to work on first?

These questions sit under every performance conversation and every concurrency feature in the rest of this part. Transitions, Actions and Suspense are all ways of telling the scheduler something about an update. You can't reason about them until you can predict what a plain setState does.

The problem: typing that feels sticky#

Here's a small form with one text input and an unrelated panel that's slow to render (it burns 60 ms of CPU each time with slowDown from guide-tools). Type a few characters quickly. The panel doesn't use the text at all, yet its render counter climbs with every keystroke and the input lags behind your fingers.

An unrelated panel re-renders on every keystroke
import { useState } from "react";
import { Rendered, slowDown } from "guide-tools";

function SlowPanel() {
  slowDown(60); // pretend this is a big chart
  return (
    <Rendered label="SlowPanel">
      <p>I don't care what you type.</p>
    </Rendered>
  );
}

export default function App() {
  const [name, setName] = useState("");
  return (
    <Rendered label="App">
      <label>
        Your name <input value={name} onChange={(e) => setName(e.target.value)} />
      </label>
      <p>Hello, {name || "stranger"}.</p>
      <SlowPanel />
    </Rendered>
  );
}

Nothing here is a bug in the sense of wrong output. The screen is correct. But every keystroke costs at least 60 ms of main thread time, and the browser can't paint the new character until React is done. To fix it you need to know three things: what starts a render, how far a render spreads, and where React lets you cut it off.

What starts a render#

A render in React means one thing: React calls your component function (or a class's render method) to get a fresh description of its UI. It's the render phase from your toy: pure computation that produces elements and fibers, with no DOM changes yet. The commit is the separate step that applies whatever changed to the DOM and then runs effects.

Only a handful of things start a render:

  1. The initial render. root.render(<App />) renders the whole tree once.
  2. A state update in the component itself: a useState setter, a useReducer dispatch, or forceUpdate/setState in a class.
  3. A context change. When a provider's value changes (compared with Object.is), every component that reads that context with useContext or use is scheduled to render.
  4. Its parent rendered. This is the one that surprises people, and it gets its own section below.

Note what's missing: "its props changed". Props are just the arguments the parent passed when the parent rendered. A child can't receive new props without its parent rendering first, so "props changed" is never an independent trigger. It's a consequence of rule 4.

A render isn't a DOM update#

A component can render without anything changing on screen. In the sandbox above, SlowPanel rendered dozens of times, but its <p> never changed, so the commit phase had nothing to write for it. That's why "re-render" isn't automatically a performance problem. The cost is the time spent calling your functions and diffing their output. When that time is small, re-rendering is cheap and fine. It only matters when a component is slow, as SlowPanel is, or when thousands of them render at once.

How far a render spreads#

When a component's state changes, React renders that component and then, by default, every component it rendered, all the way down. Props don't need to change. React doesn't even check.

Why not check? Because React can't know that your component is a pure function of its props. It might read a ref, a module variable, the current time or a context value. The only safe default is to call it again and compare the output. Comparing props first is an optimization you opt into (with memo, in the memoization chapter, or automatically with the React Compiler). Without that opt-in, the rule is simple and predictable: a render flows down through the subtree.

Click around in the diagram. Pick a component to set state in, and watch which counters move.

Re-render propagation
Main renders:
Headerrenders: 1Sidebarrenders: 1Post Arenders: 1Post Brenders: 1Feedrenders: 1Mainrenders: 1Apprenders: 1Every component is created by its parent.
Set state in:

Pick a component to call its state setter. Highlighted boxes are the ones that rendered for that update.

A render starts at the component whose state changed and flows down through every element that component created. Props don't have to change. In the second mode, App creates Sidebar and Feed and passes them to Main as children, so Main's own updates can't reach them.

The interesting part is the second mode. The tree looks identical, but now App creates the <Sidebar /> and <Feed /> elements and hands them to Main as children. When Main sets state, it re-renders, but the children prop it received is the same element objects as last time. React sees an identical element (same object, so same props) and skips that whole subtree. The render only spreads through elements that the updating component created during this render.

That's the real rule, stated precisely: a component re-renders if its state or a context it reads changed, or if its parent rendered and passed it a new element. Every time a component's function runs, the JSX inside it creates brand-new element objects with brand-new props objects. Elements created somewhere else and passed in are reused as they are.

The two escapes that need no memo#

That rule gives you two refactors that fix most "too many renders" problems before you reach for any memoization.

Move state down. If only part of a component uses a piece of state, pull that part and its state into its own component. In the opening example, only the input and the greeting need name. Put them in a NameForm component and App stops rendering on every keystroke, which means SlowPanel does too. You'll do exactly that in an exercise below.

Lift content up (children as props). Sometimes the state really belongs in a wrapper, like a component that tracks hover or scroll position and needs to wrap expensive content. Then let the wrapper take the expensive part as children, so the element is created by a component that isn't changing.

Same wrapper, two ways

Click both toggle buttons and compare the counters on the two ExpensiveTree boxes.

import { useState, type ReactNode } from "react";
import { Rendered, slowDown } from "guide-tools";

function ExpensiveTree() {
  slowDown(40);
  return <Rendered label="ExpensiveTree">Lots of UI</Rendered>;
}

// Version 1: the wrapper creates the expensive element itself.
function HighlighterOwnsTree() {
  const [on, setOn] = useState(false);
  return (
    <Rendered label="HighlighterOwnsTree" style={{ background: on ? "#fde68a" : undefined }}>
      <button onClick={() => setOn(!on)}>Toggle highlight</button>
      <ExpensiveTree />
    </Rendered>
  );
}

// Version 2: the wrapper receives the element as children.
function Highlighter({ children }: { children: ReactNode }) {
  const [on, setOn] = useState(false);
  return (
    <Rendered label="Highlighter" style={{ background: on ? "#fde68a" : undefined }}>
      <button onClick={() => setOn(!on)}>Toggle highlight</button>
      {children}
    </Rendered>
  );
}

export default function App() {
  return (
    <>
      <HighlighterOwnsTree />
      <Highlighter>
        <ExpensiveTree />
      </Highlighter>
    </>
  );
}

In the second version App creates <ExpensiveTree /> once. Highlighter re-renders on every toggle, but the children it returns is the same element object, so React skips it. No memo, no useMemo, just a different owner for the element.

Context skips the line#

Context is the exception to "renders flow down from the updater". When a provider's value changes, React finds every component that reads that context and renders it, even if a component in between bailed out. That's useful (a deep consumer always sees the new value) and a classic source of surprise: a provider value written as an object literal, value={{ user, setUser }}, is a new object on every render of the provider's owner, so every consumer renders every time. The context chapter covers splitting contexts and stabilizing values.

Render and commit, revisited#

You built both phases in the toy. Real React keeps the same split, with stronger guarantees on each side.

The render phase calls components, runs hooks, reconciles children and builds the work-in-progress fiber tree. It must be pure: no DOM writes, no subscriptions, no network calls, no mutation of anything that existed before the render. React relies on that purity in three ways. It may render a component and throw the result away (an interrupted transition, a render that suspended). It may render twice in development under <StrictMode> to flush out impurities. And it may render a component more than once before committing when a higher-priority update cuts in.

The commit phase is synchronous and can't be interrupted. React applies DOM mutations, attaches refs, runs layout effects (useLayoutEffect), lets the browser paint, and then runs passive effects (useEffect). Once a commit starts, the user will see a consistent result. That's the whole reason the phases are split: interruptible work happens where nothing is visible yet, and the visible part happens in one go so the screen never shows half an update.

Batching, brieflyDeep dive

Since React 18, every update is batched: several setter calls in the same event, timeout or promise callback queue up and produce one render. Your toy did the same thing by scheduling a render instead of rendering inside the setter. The state chapter shows the snapshot behavior that falls out of it. Batching is what makes priorities possible: updates sit in a queue first, so React gets to choose when and in what order to process them.

Not every update is equally urgent#

So far every update has been treated the same. In a real app they aren't. A keystroke in an input has to show up within a frame or two, or typing feels broken. The search results filtered by that keystroke can arrive a little later and nobody minds. A hidden tab's content can wait until there's nothing else to do.

Your toy's work loop could already pause between fibers. What it couldn't do is decide that one piece of work matters more than another. Real React does that with lanes.

Lanes, conceptually#

A lane is a priority level for an update. Internally each one is a bit in a 31-bit number, so a set of pending priorities is just a bitmask, and "is there anything more urgent pending?" is a cheap bitwise check. When you call a setter, React assigns the update a lane based on where the call came from:

Update priorities (conceptual)
LaneTypical sourceTime-sliced?Syncclick, keydown, input, flushSyncnoContinuous inputmousemove, scroll, pointermovenoDefaultsetTimeout, a resolved fetch, root.rendernoTransitionstartTransition, useDeferredValue, ActionsyesRetrya suspended boundary trying againyesIdle / Offscreenhidden <Activity> contentyes
A simplified view of React's lanes in 19.3.1. Higher rows win. Only the lower rows are time-sliced: React renders fibers for about 5 ms, yields to the browser, then continues with whatever is most urgent. The urgent lanes render in one go.
  • A setter called inside a click, key press or input handler gets the sync lane. React renders and commits it before the browser does anything else, flushed in a microtask at the end of the event. That's why controlled inputs work: the new value is committed before the next keystroke arrives.
  • Continuous events like mousemove and scroll get a slightly lower lane, so a flood of them doesn't starve clicks.
  • Updates from outside any event (a setTimeout, a resolved fetch, the initial root.render) get the default lane.
  • Updates inside startTransition get one of several transition lanes. The next chapter is about these.
  • Suspense retries, idle work and the content of a hidden <Activity> sit lowest.

When React picks what to do next, it takes the highest-priority lanes that have pending work. If it's in the middle of rendering a transition and a click arrives, it can drop the half-built work-in-progress tree, handle the click (render and commit), and then restart the transition from the new state. Starting over is safe precisely because the render phase is pure.

Time slicing only applies to non-urgent work#

Here's a detail that trips up even experienced engineers: in React 19.3.1, the urgent lanes (sync, continuous and default) render without yielding. Once React starts them, it finishes the whole render in one go. Only transition, retry, idle and offscreen work runs in the interruptible loop, where React renders fibers until about 5 ms have passed (the scheduler's default frame budget), then yields the main thread so the browser can handle input and paint before React continues.

That's why the opening sandbox lags even though React is "concurrent". Every keystroke is a sync update, and its render includes the 60 ms panel, so the main thread is blocked for 60 ms per keystroke. Concurrency doesn't kick in by itself. You opt in by marking work as non-urgent.

flushSync: commit right now#

Batching and scheduling mean the DOM isn't updated when your setter returns. Most of the time that's what you want. Occasionally you need the DOM updated before the next line runs, usually to measure it, scroll to something you just rendered, or hand control to code outside React that reads the DOM.

flushSync from react-dom does that. It runs the callback, then synchronously renders and commits every update scheduled inside it (and any other pending sync work) before returning.

Scroll to the item you just added

Add items with each button. Without flushSync, the scroll lands on the previous last item, because the new one isn't in the DOM yet when scrollIntoView runs.

import { useRef, useState } from "react";
import { flushSync } from "react-dom";

export default function App() {
  const [items, setItems] = useState(["Item 1", "Item 2", "Item 3"]);
  const listRef = useRef<HTMLUListElement>(null);

  function scrollToLast() {
    const last = listRef.current!.lastElementChild as HTMLElement;
    last.scrollIntoView({ block: "nearest" });
    last.style.outline = "2px solid #b4532a";
    setTimeout(() => (last.style.outline = ""), 600);
  }

  function addBatched() {
    setItems((xs) => [...xs, `Item ${xs.length + 1}`]);
    scrollToLast(); // the new <li> doesn't exist yet
  }

  function addFlushed() {
    flushSync(() => {
      setItems((xs) => [...xs, `Item ${xs.length + 1}`]);
    });
    scrollToLast(); // committed: the new <li> is in the DOM
  }

  return (
    <>
      <button onClick={addBatched}>Add (batched)</button>{" "}
      <button onClick={addFlushed}>Add (flushSync)</button>
      <ul ref={listRef} style={{ height: 120, overflow: "auto", border: "1px solid #d6d3d1" }}>
        {items.map((item) => (
          <li key={item}>{item}</li>
        ))}
      </ul>
    </>
  );
}

flushSync is an escape hatch with real costs. It forces a synchronous render, which defeats batching. The docs also warn that it may run pending effects first and may force pending Suspense boundaries to show their fallbacks. React warns if you call it from inside a render or a lifecycle method, because there's no way to flush synchronously while already rendering. Reach for it when you must read the DOM right after an update and there's no better place (a layout effect is often the better place). Don't reach for it to "make updates faster".

Pitfalls#

Check your understanding#

PredictWho renders?

Layout owns some state and receives its content as children. You click Toggle once. Which render counters change?

function Stats() {
  return <Rendered label="Stats">42 visitors</Rendered>;
}

function Footer() {
  return <Rendered label="Footer">Footer</Rendered>;
}

function Layout({ children }: { children: ReactNode }) {
  const [dark, setDark] = useState(false);
  return (
    <Rendered label="Layout">
      <button onClick={() => setDark(!dark)}>Toggle</button>
      {children}
      <Footer />
    </Rendered>
  );
}

export default function App() {
  return (
    <Rendered label="App">
      <Layout>
        <Stats />
      </Layout>
    </Rendered>
  );
}
Fix itStop the slow panel from re-rendering

Typing in the color field re-renders SlowPanel on every keystroke. Fix it without touching SlowPanel and without memo. The checks type into the field and expect the panel to have rendered only once.

import { useState } from "react";
import { slowDown, useRenderCount } from "guide-tools";

// Don't change this component.
function SlowPanel() {
  const renders = useRenderCount();
  slowDown(150);
  return <p>Slow panel renders: {renders}</p>;
}

export default function App() {
  const [color, setColor] = useState("");
  return (
    <div>
      <label>
        Favorite color <input value={color} onChange={(e) => setColor(e.target.value)} />
      </label>
      <p style={{ color }}>Preview: {color}</p>
      <SlowPanel />
    </div>
  );
}
PredictWhat does the DOM say?

The <span> starts at 0. You click the button once. What are the two console lines, and what does the span show at the end?

function Counter() {
  const [count, setCount] = useState(0);
  const ref = useRef<HTMLSpanElement>(null);

  function handleClick() {
    flushSync(() => setCount((c) => c + 1));
    console.log("after flushSync:", ref.current!.textContent);
    setCount((c) => c + 1);
    console.log("after setCount:", ref.current!.textContent);
  }

  return (
    <button onClick={handleClick}>
      <span ref={ref}>{count}</span>
    </button>
  );
}
Quick checkIt rendered anyway

A child component's props are exactly the same as last time, it isn't wrapped in memo, and the React Compiler isn't used. Its parent just set state. What happens to the child?

Quick checkWhich work can be interrupted?

In React 19.3.1, which of these renders can React pause partway through to handle a click?

Explain it out loudWhy did my child re-render?

An interviewer asks: "When does a React component re-render, and why does a parent's re-render re-render its children even if their props didn't change?"

Interview angle

Say it in 30 seconds

A render is React calling your component to get a new description of the UI. It starts from a state update, a context change, or a parent rendering a new element for the component, and by default it flows down through everything that component created, whether or not props changed. Render is pure and interruptible; commit applies DOM changes synchronously. Each update gets a priority, called a lane, from where it was scheduled: event handlers are urgent and render to completion, while transitions are time-sliced and can be interrupted and restarted when something more urgent arrives.

What causes a React component to re-render?

basic

Why does a child re-render when its parent re-renders, even if its props are the same?

intermediate

A user types without pausing, and every keystroke interrupts a slow transition. Can that transition be starved forever?

senior

How does React decide which update to process first?

senior

What does flushSync do and when would you use it?

intermediate

React 18 made rendering concurrent. So why does typing still lag when a slow component re-renders on each keystroke?

senior

Recap#

  • A render is React calling your component. Only the initial render, a state update, a context change or a parent rendering a new element for it can start one. "Props changed" is a consequence of the last one.
  • By default a render flows through every element the updating component created. Elements passed in as children were created elsewhere and are skipped, which is why moving state down and lifting content up fix most re-render problems without memo.
  • The render phase is pure and can be thrown away, repeated or restarted. The commit phase is synchronous and all-or-nothing.
  • Updates get priorities (lanes) from where they're scheduled. Urgent lanes render to completion; transition, retry, idle and offscreen work is time-sliced and can be interrupted and restarted.
  • flushSync forces a synchronous render and commit, for the rare case where you must read the DOM right after an update.

Sources#

  • react.dev: Render and Commit
  • react.dev: Preserving and resetting state
  • react.dev: useState (bailing out on identical values)
  • react.dev: flushSync
  • react.dev: useTransition (interruption and restart)
  • React 19.3.1 source, react-dom-client.development.js (lane assignment, time-slicing condition, expiration times) and scheduler (5 ms frame interval), as installed in the guide's sandbox runtime
  • Facts checked November 24, 2026.