0Pricing
React Academy · Lesson

The Rendering Phase and DOM Commit

Trace React's render cycle from JSX evaluation through reconciliation to the browser's paint step.

The Rendering Phase and DOM Commit is a free React Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the React Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

React Work Cycle Overview

React's work cycle has two main phases: the render phase and the commit phase. During the render phase, React calls your component functions and builds a virtual representation of the UI (the fiber tree). During the commit phase, React applies the changes from the fiber tree to the real DOM.

The Render Phase Can Be Interrupted

In React 18 Concurrent Mode, the render phase can be paused, interrupted, or restarted. React may call your component function multiple times before committing anything. This is why component functions must be pure — they cannot have side effects, because the function might run more than once per visible update.

The Commit Phase Is Always Synchronous

Unlike the render phase, the commit phase is always synchronous and runs to completion. React cannot be interrupted while committing DOM changes. This ensures the DOM is never left in a partially updated state. Users always see a fully consistent UI after each commit.

Three Sub-Phases of Commit

The commit phase has three sub-phases: before mutation (class component getSnapshotBeforeUpdate runs here to read DOM values before changes), mutation (React inserts, updates, and removes DOM nodes), and layout (synchronous effects fire here, specifically useLayoutEffect and class component componentDidMount/componentDidUpdate).

Passive Effects: useEffect

useEffect is a passive effect, meaning it is not run during the commit phase. After the commit phase completes and the browser has painted, React schedules passive effects asynchronously. They run after the browser has had a chance to render the updated DOM to the screen.

Browser Paint Timing

The browser paints between the layout phase (where useLayoutEffect runs) and the passive effects phase (where useEffect runs). This is the critical timing difference: useLayoutEffect runs before paint, and useEffect runs after paint. For effects that change visual output, this distinction matters greatly.

Why useEffect Can Cause a Double Visual Update

If a useEffect reads the DOM and updates state (for example, measuring an element and setting a size state), React will re-render and commit again. The browser paints twice: once with the initial size and once with the corrected size. Users may see a flash of the wrong size before the correction appears.

The Fiber Tree

React builds a tree of "fiber" nodes internally, one per component instance. Each fiber holds the component's state, effects, and output. During the render phase, React creates a new work-in-progress fiber tree. During the commit phase, the work-in-progress tree becomes the current tree, and the old tree is recycled.

Double Invocation in Strict Mode

React Strict Mode intentionally calls component functions and effects twice in development to help catch side effects. Both useLayoutEffect and useEffect are mounted, unmounted, and remounted. This double invocation does not happen in production. It is designed to surface bugs where effects are not properly cleaned up.

Why Component Functions Must Be Pure

Because the render phase can be interrupted and re-run, component functions must produce the same output for the same inputs without side effects. Mutations, subscriptions, and API calls in the function body (not in effects) will run more times than expected in Concurrent Mode, leading to bugs.

Reading DOM in Render vs Effects

Never read DOM properties directly inside the component function body. The DOM may not yet exist (for server rendering) or may be stale (for re-renders). Always read the DOM inside useLayoutEffect (for pre-paint reads) or useEffect (for post-paint reads) where the DOM is guaranteed to be up to date.

React Commit Phase Sub-Phases

In which sub-phase of the React commit phase does useLayoutEffect fire?

Lesson Recap: Rendering Phase and DOM Commit

React's render phase builds the fiber tree and can be interrupted; the commit phase applies DOM changes and is always synchronous. The commit has three sub-phases: before mutation, mutation, and layout. useLayoutEffect fires in the layout phase before paint. useEffect fires as a passive effect after paint.

Frequently asked questions

Is the “The Rendering Phase and DOM Commit” lesson free?

Yes — the full text of “The Rendering Phase and DOM Commit” is free to read here on the web, and the React Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the React Academy course, upgrade to CoddyKit PRO.

What will I learn in “The Rendering Phase and DOM Commit”?

Trace React's render cycle from JSX evaluation through reconciliation to the browser's paint step. You practise React Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start React Academy?

No prior experience is required. React Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “The Rendering Phase and DOM Commit” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this React Academy lesson?

Yes. Every React Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. The Rendering Phase and DOM Commit
  2. When useLayoutEffect Runs vs useEffect
  3. Measuring DOM Elements with useLayoutEffect
  4. Avoiding Layout Thrash and Visual Flicker
← Back to React Academy