How React renders · mid
Render and commit: the two phases of an update
Every screen update goes trigger, then render (React calls your components to compute the next UI; this must be pure and may be paused or thrown away), then commit (React applies only the DOM changes that differ, attaches refs, then runs effects).
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Two triggers: the first render (
root.render()), and a state update in the component or one of its ancestors (setState, dispatch, an external store change). A changed prop is not a trigger by itself; the parent re-rendering is. - Render phase = React calling components and computing the new tree. It must be pure: same props, state and context give the same JSX, and no side effects (no fetch, no subscriptions, no changing outside variables).
- Concurrent rendering can pause, restart or discard a render. Side effects in the component body can run for UI that never appears on screen.
- Commit phase is synchronous: React changes only the DOM nodes that differ, attaches refs, runs layout effects (before paint), then the browser paints, then passive effects (
useEffect) run. - Changing a local variable or array you just created during render is fine ("local mutation"). Changing props, state, context or module variables is not.
- StrictMode (development only) calls each component twice to find impure renders. In React 19 the second call reuses the
useMemo/useCallbackresults of the first.
The red pen
Common traps: mistake → fix
Mistake: "Render means the DOM was updated"
Fix: render only calculates; commit changes the DOM, and only where something differs.
Mistake: "A fetch or analytics call in the component body runs once"
Fix: it can run many times: StrictMode, re-renders, and interrupted concurrent renders.
Mistake: "Impure render only hurts in development"
Fix: concurrent features in production (transitions, Suspense) also restart or discard renders.
Easy to hard
Questions interviewers ask, easy to hard
- What is the difference between rendering and committing?
- What must code in a component body never do, and why?
- When are refs attached, and when do
useLayoutEffectanduseEffectrun compared with paint? - Concurrent rendering can throw work away. Give an example of an impure render that breaks because of it.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.