Home / Learn React / How React Renders
How React Renders
To debug state and effects you need to know what a render is. React works in three steps: trigger, render and commit.
Theory in plain words
What it is
Rendering is React calling your component functions to find out what should be on the screen. Committing is applying the difference to the real browser DOM.
Why we use it
If you know when a component runs, you know why a log prints twice, why state looks old inside an handler and how to keep your app fast.
How it works
A render is triggered by the first mount or by a state change. React renders (calls components) top down. It compares the result with the previous one and commits only the changes to the DOM. Then the browser paints and effects run.
Where it is used
- Understanding re-renders and performance
- Writing correct effects
- Debugging "why is my state old?"
- Learning how StrictMode finds bugs
Components must be pure
A pure function gives the same output for the same input and changes nothing outside itself. React components should be pure while they render: do not change outside variables, do not call Math.random() or read Date.now() to build the output, and do not mutate props or state.
Open the console area under the result. When App renders, all its children render too, even if their props did not change.
What triggers a re-render?
- A state change in that component (
setXwith a different value). - The parent rendered (children render again by default).
- A context value that the component reads changed.
React skips a render if you set state to the same value (it compares with Object.is).
Virtual DOM in one minute
React keeps a lightweight description of the UI in memory. After each render it compares the new description with the old one (diffing) and updates only the real DOM nodes that changed. You do not manage that. It is why you can "redraw everything" in your code and it stays fast.
StrictMode
In development, <StrictMode> renders every component twice and runs every effect twice on mount, to expose impure code and missing cleanups. It does nothing in the production build. If you see a log twice during development, this is usually why.
Quick quiz
1. What are the three steps of rendering?
Trigger, render, commit.
2. Does a parent re-render re-render its children by default?
Yes, unless you use memo or the child is the same element.
3. What does StrictMode do in development?
It helps find impure rendering and missing cleanup.
4. A component must be...
Same inputs give the same output and no outside changes.
Common questions
What are the three steps of rendering?
Trigger, render, commit. Trigger, render, commit.
Does a parent re-render re-render its children by default?
Yes. Yes, unless you use memo or the child is the same element.
What does StrictMode do in development?
Renders twice and re-runs effects to expose bugs. It helps find impure rendering and missing cleanup.