React rendering model
Reconciliation, keys, memoization, when re-renders actually matter. "Why does this component render 40 times?" is a standard screen.
The mental model
React is a reconciler, not a renderer in the browser sense. You never tell React "change this DOM node." You hand it a description of what the UI should look like *right now* — a tree of elements — and React figures out the smallest set of DOM operations that turns the current screen into that description. The mental shift that fixes most confusion: your component functions are called to produce a description; the DOM is a side effect React performs afterwards.
The analogy that sticks: React is a document diffing tool like the thing that powers "track changes" in a word processor. Each time state changes, you write a fresh copy of the document (call the component, get new elements). React compares the new copy against the last committed copy and produces a redline — insert this node, update that attribute, delete this subtree. The DOM is the printed page; the redline is the commit. A "re-render" is React calling your function and producing a new copy for comparison. It is not — and this is the single most expensive misconception in the ecosystem — the same thing as the browser repainting pixels.
Why this design exists: direct DOM manipulation does not compose. Ten features each poking element.textContent step on each other, and the DOM becomes the single mutable source of truth that every feature races to update. React makes the *description* the source of truth and owns the mutation. The cost is that React re-runs your functions a lot, so the whole performance discipline of React is controlling what re-runs and making each run cheap — keys so the diff is stable, memoization so subtrees are skipped, and state placed low so a change touches the fewest components.
- Deep dive
- Internal architecture
- Real-world use cases
- Best practices
- Common mistakes
- Performance
- Security
- Production troubleshooting
- Advantages & disadvantages
- Alternatives
- Interview expectations
- Interview questions
- Facts to remember
- Cheat sheet
- Quick revision