liveBook · Manning

Commit

As explained in Acing the Frontend Interview

The React rendering phase in which the computed interface changes are applied to the host environment.

Commit is the final phase of a React update: the point when prepared changes are applied to the real DOM. Rendering first builds a work-in-progress tree without changing the DOM; pre-commit prepares the updates. After reconciliation identifies the needed changes, commit applies them synchronously and irreversibly. section 4.1

To distinguish commit from the work before it, trace what becomes observable:

  • Render prepares a representation of the next UI; it does not yet update the real DOM. section 4.1
  • Pre-commit batches and checks pending changes so the UI avoids an intermediate, partially rendered state. Class components may run getSnapshotBeforeUpdate() here. section 4.1
  • Commit updates the DOM and sets up refs and layout effects. This phase also includes effect hooks and class lifecycle methods such as componentDidMount() and componentDidUpdate(). section 4.1

Interview follow-up

If asked how React moves from a Virtual DOM comparison to a visible update, name the render, pre-commit, and commit phases. Then identify commit as the actual DOM-update step, rather than saying that building the work-in-progress tree changes the page. Connect batching and changes limited to affected components to fewer costly DOM manipulations. section 1.3 section 4.1

Figure 4.4 React's rendering process: render, pre-commit, and commit phases.

Use the phase diagram to locate commit after render and pre-commit, where prepared work becomes a real DOM update. section 4.1

How Acing the Frontend Interview covers it

How deep it goes
Explains the three-phase sequence, synchronous DOM changes, refs, effects, and class lifecycle calls without detailing commit internals.
Examples
Uses an interview follow-up about Virtual DOM updates and a render–pre-commit–commit diagram.
What it assumes
Assumes familiarity with React and the DOM while explaining the work-in-progress tree and rendering phases.
What you can do after
Evaluate/understand where an update changes the DOM and explain that distinction in a React interview.
How it connects
Connects commit to the Virtual DOM, reconciliation, the work-in-progress tree, batching, effects, and DOM performance.

Also explained in

Compare how 8 books explain commit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Frontend Interview. The section links point to the parts of the book it draws on.