Skip to main content

commit phase VS render phase

Short answer:

React goes through two phases of updating the interface:

PhaseWhat it doesCan it be interrupted?Where it runs
Render phaseComputes what needs to be updated (builds a new virtual tree)YesIn memory (Virtual DOM)
Commit phaseApplies these changes to the real DOMNoIn the browser (DOM)

1. Render Phase (the computation / preparation phase)

Here React determines which parts of the interface need to be updated, but doesn't touch the DOM yet.

What happens:

  • React calls the components (or render() for class ones);
  • builds a new tree of Fiber nodes (a virtual tree);
  • compares it with the old tree (diffing algorithm);
  • decides which nodes:
    • need to be created,
    • which need to be updated,
    • which need to be removed.

Important: At this stage the user sees no changes - everything happens "in memory".

Features:

  • React can pause this phase (asynchronous rendering);
  • can restart it from scratch (if, for example, new data arrives);
  • can change the priority of tasks (user input is more important than a list update).

Example:

If you called setState(…), React first creates a new virtual tree - but doesn't update the DOM right away.


2. Commit Phase (the application phase)

Here React makes the real changes to the DOM and calls the corresponding lifecycle hooks.

What happens:

  • React applies all accumulated changes:
    • adds/removes/updates real DOM elements;
    • runs effects (useEffect, componentDidMount, componentDidUpdate);
    • calls layout effects (useLayoutEffect).

Once the commit phase finishes, the user sees the updated UI.

Features:

  • This phase cannot be interrupted (otherwise the UI would end up in a "half state");
  • Runs very quickly - usually within milliseconds;
  • React applies changes in one batch to avoid flicker.

Illustration of the process

javascript
setState() → the Render phase begins React calls the components → creates a new Virtual DOM React compares the old and new tree (diffing) Decides what to update, remove, add (can be paused / resumed) Render phase finished → the Commit phase begins React makes the real changes to the DOM useLayoutEffect and useEffect run The user sees the updated UI

The difference through an analogy

Imagine React is a builder

StageWhat React doesAnalogy
Render PhasePlans what needs to change: draws up a new house planAn architect makes a blueprint
Commit PhaseTurns changes into reality: moves the walls and furnitureBuilders do the renovation according to the plan

What you can and cannot do in these phases

ActionRender PhaseCommit Phase
Call hooks (useState, useContext, useMemo)YesNo
Change the DOM directlyNoYes
Run side effects (useEffect)NoYes
Compute JSXYesNo
Work with layout (useLayoutEffect)NoYes

Example with hooks:

javascript
function Example({ count }) { useEffect(() => { console.log('useEffect - Commit phase'); }); console.log('Component render - Render phase'); return <div>{count}</div>; }

When count updates:

  • First React calls the component (Render phase);
  • Then it updates the DOM (Commit phase);
  • After that it runs useEffect.

Summary

ParameterRender PhaseCommit Phase
GoalCompute what needs to be updatedApply the changes
Where it runsIn memory (Virtual DOM / Fiber tree)In the browser (the real DOM)
Can be interruptedYesNo
DurationCan be longVery short
Side effectsDon't runRun
HooksuseMemo, useState, useContextuseEffect, useLayoutEffect

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.