How it works
In React 19.3.1, reconciliation happens per fiber while rendering (implementation details from ReactChildFiber.js). When a component returns a single element, reconcileSingleElement looks for an old child with the same key (both null when unkeyed), then checks child.elementType === element.type. A match reuses the fiber with new props; a mismatch marks the old fiber and everything below it for deletion and creates a new one. Arrays go through reconcileChildrenArray, which walks old and new children in step until a key differs, then falls back to a map of the remaining old children by key (or by index when unkeyed).
The render phase only records flags (placement, update, deletion). The commit performs them, which a MutationObserver makes visible:
const container = document.getElementById('root');
const root = createRoot(container);
const observer = new MutationObserver(() => {});
observer.observe(container, { subtree: true, childList: true, attributes: true, characterData: true });
const describe = (r) =>
r.type === 'attributes' ? `set ${r.attributeName}`
: r.type === 'characterData' ? 'set text'
: r.addedNodes.length ? `insert ${r.addedNodes[0].nodeName}` : `remove ${r.removedNodes[0].nodeName}`;
function render(element) {
flushSync(() => root.render(element));
console.log(observer.takeRecords().map(describe).join(', '));
}
render(<div className="a"><b>{'hi'}</b></div>); // → insert DIV
render(<div className="b"><b>{'hi'}</b></div>); // → set class
render(<div className="b"><b>{'bye'}</b></div>); // → set text
render(<section className="b"><b>{'bye'}</b></section>); // → remove DIV, insert SECTION
Chrome 156 and Firefox 159, development and production builds. The <b> and its text in the last step were identical, but they sat under a new type, so they were rebuilt too.
Edge cases
memo and forwardRef return new types. Switching a slot between Field and memo(Field), or between a plain component and a forwardRef one, remounted it.
- Fragments. Going between
<Child />, <><Child /></> and [<Child />] keeps state; a second Fragment level resets it.
- Same tag, different attributes.
<input type="text"> → <input type="number"> is the same type; React updated type on the existing node.
- Hot reloading. Development builds also accept a hot-reloaded version of the same component as a match (
isCompatibleFamilyForHotReloading in the source), so state can survive an edit.
null and false hold positions. {a && <X />}<Y /> keeps Y in the second slot whether or not X renders.
Real-world scenario
A page renders isMobile ? <MobileLayout>{form}</MobileLayout> : <DesktopLayout>{form}</DesktopLayout>. Rotating a tablet flips isMobile, and the half-filled form empties: different layout types at the same position, so the form below them was unmounted. Fixes, best first: one layout component that changes with CSS or props; lift the form's state above the switch; or render the form outside the layout-specific wrapper.
Trade-offs
React's heuristic keeps reconciliation linear, at the price of rare rebuilds where a cleverer diff would patch. The bigger trade-off is the model itself. Re-running components and diffing their output is work that a library compiling templates to direct DOM updates avoids; in exchange, React components are plain functions of state, and the diff makes that affordable. When the diff itself is too slow, the fixes are rendering less (memo, the React Compiler, moving state down) rather than avoiding React's DOM updates.