# Virtual DOM & Reconciliation vs Signals and Fine-Grained Reactivity (Reactive Graph)

- **Canonical URL:** https://frontend.rocks/vs/virtual-dom-reconciliation-vs-fine-grained-signals/
- **Relation:** Contrasts With
- **Last Verified:** 2026-11-15
- **Verdict:** VDOM diffs whole component subtrees on state changes; Signals update subscribed DOM nodes in O(1).

## Comparison Matrix

| Dimension | Virtual DOM & Reconciliation | Signals and Fine-Grained Reactivity (Reactive Graph) |
| :--- | :--- | :--- |
| **Maturity** | Baseline · Widely | Experimental |
| **Domain** | State & Architecture | State & Architecture |
| **Mental Model** | Diffs lightweight JS element trees in O(n) using type and key heuristics, batching minimal DOM mutations into a single commit phase. | Reactive model built on a directed acyclic dependency graph (Signal, Computed, Effect) updating only subscribed DOM nodes without virtual tree diffing. |
| **Prerequisites** | None | Event Loop, Macrotasks, and Microtask Queue (Reactive effect batching commonly relies on a microtask flush.) |
| **When Not to Use** | When not to use VDOM: For high-frequency 60 fps canvas/drag coordinates or 10,000-cell spreadsheets, bypass VDOM diffing and update CSS transforms or signals directly. | When not to use Signals: For simple forms or mostly static pages, native DOM primitives avoid unnecessary abstraction overhead; for multi-step workflows with illegal state combinations, pair or replace raw signals with Finite State Machines. |

## Virtual DOM & Reconciliation — Under the Hood
Mutating the live DOM directly inside scattered event handlers easily triggers [Layout Thrashing](/concepts/layout-thrashing). A Virtual DOM acts like an architect's redline markup: you sketch the entire next UI state in plain JS objects first, compare against the previous blueprint, and hand the browser only the final delta.

1. **Render phase**: Component functions execute and allocate a fresh tree of plain JS descriptors (`{ type, key, props }`), which is interruptible in concurrent schedulers.
2. **Heuristic diff**: Same `type` and `key` reuses the underlying DOM node and patches changed attributes; a changed `type` destroys and remounts the entire subtree.
3. **Commit phase**: The runtime applies all collected DOM insertions, removals, and attribute writes in one synchronous pass, contrasting with [Fine-Grained Signals](/concepts/fine-grained-signals) that bypass tree diffing altogether.

```jsx
// Stable domain IDs preserve DOM identity across reorders
function TaskList({ tasks }) {
  return tasks.map((task) => (
    <TaskRow key={task.id} title={task.title} />
  ));
}
```

## Signals and Fine-Grained Reactivity (Reactive Graph) — Under the Hood
1. **Automatic Tracking**: When a `computed` or `effect` runs, it pushes its context onto a global tracking stack; each `signal.get()` adds a `signal -> observer` edge.
2. **Push-Pull Propagation**: Calling `signal.set(v)` marks descendants `Dirty` (Push) without eagerly recomputing lazy derived values, avoiding wasted [V8 Hidden Classes](/concepts/v8-hidden-classes-ic) allocations on unused branches.
3. **Lazy Evaluation (Pull)**: A `computed` only recomputes when read, and short-circuits downstream effects (often flushed on the [Event Loop](/concepts/event-loop-tasks-microtasks) microtask checkpoint) if its new value equals the previous one.

```js
const count = signal(1);
const doubled = computed(() => count.get() * 2);

effect(() => {
  // Re-runs ONLY when `doubled` actually changes
  badgeEl.textContent = String(doubled.get());
});
```

## Interactive Labs & Dissections
- [Virtual DOM & Reconciliation Lab](https://frontend.rocks/concepts/virtual-dom-reconciliation/#lab) ([Markdown](https://frontend.rocks/concepts/virtual-dom-reconciliation.md))
- [Signals and Fine-Grained Reactivity (Reactive Graph) Lab](https://frontend.rocks/concepts/fine-grained-signals/#lab) ([Markdown](https://frontend.rocks/concepts/fine-grained-signals.md))

## Related Architecture Autopsies
- [Autopsy #03: Why One Click Triggers 14 Re-Renders and a Layout Shift](https://frontend.rocks/autopsies/fourteen-rerenders-one-click/) ([Markdown](https://frontend.rocks/autopsies/fourteen-rerenders-one-click.md)): A single filter click freezes the UI for 180 ms INP and triggers a visible 0.14 CLS jump in the data grid.
- [Autopsy #13: The useEffect Dependency Loop That DDoSed Our Own API](https://frontend.rocks/autopsies/useeffect-dependency-loop-ddos/) ([Markdown](https://frontend.rocks/autopsies/useeffect-dependency-loop-ddos.md)): Changing a single URL filter triggers an infinite render loop, Maximum update depth exceeded, and a burst of 429 Too Many Requests responses.

## Primary Sources
- https://react.dev/learn/preserving-and-resetting-state
- https://react.dev/learn/rendering-lists#why-does-react-need-keys
- https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model
- https://github.com/tc39/proposal-signals
