DEV Community

Cover image for ⚑ React Internals: Virtual DOM πŸ–ΌοΈ vs Fiber Node πŸ”— for Performance Explained
Yogesh Bamanier
Yogesh Bamanier

Posted on

⚑ React Internals: Virtual DOM πŸ–ΌοΈ vs Fiber Node πŸ”— for Performance Explained

Learn how React leverages Virtual DOM and Fiber Node to efficiently update your UI and keep apps smooth. ✨


When I first started diving deep into React, I kept wondering: β€œAre Virtual DOM and Fiber Node the same thing?” πŸ€”
The short answer is no, but they are closely related, like two teammates ⚽ with different roles in a match.


πŸ”Ή Are They the Same? What’s the Relation? 🧩

  • Virtual DOM (VDOM) πŸ–ΌοΈ: a snapshot of your UI in memory.
  • Fiber Node πŸ”—: the task manager for React, tracking updates to each component individually.

How they work together:

  1. When state or props change, React creates a new Virtual DOM tree 🌳
  2. React diffs the new VDOM with the previous VDOM πŸ” to detect changes
  3. Each detected change is represented as a Fiber Node (unit of work) βœ‚οΈ
  4. Fiber schedules these updates incrementally on the main thread, deciding what to prioritize, pause, or resume πŸ•’
  5. The real DOM is updated smoothly without blocking the UI πŸ—οΈ

In short:

  • VDOM calculates what to update
  • Fiber decides how and when to update ⚑

πŸ”Ή Virtual DOM πŸ–ΌοΈ

The Virtual DOM is an in-memory representation of the real DOM. React updates this virtual copy first, instead of touching the browser DOM directly.

How It Works:

  1. Render the UI to a Virtual DOM tree 🌳
  2. On state/props update, create a new Virtual DOM tree πŸ”„
  3. Diff the old and new VDOM to find changes πŸ”
  4. Patch only the changed parts to the real DOM πŸ—οΈ

Pros:

  • ⚑ Performance optimization – fewer direct DOM updates
  • πŸ–ŒοΈ Declarative UI – React computes changes abstractly
  • 🧠 Easier to reason about state updates and re-rendering

πŸ”Ή Fiber Node πŸ”—

Fiber is React’s reconciliation engine introduced in React 16.
Each component corresponds to a Fiber Node, a unit of work storing metadata like:

  • 🏷️ Component type
  • πŸ“ Props and state
  • πŸ”— Parent, child, sibling pointers
  • ⚠️ Effect tags (tracking updates)

Why Fiber?

Previously, React’s diffing blocked the main thread ⏳ for large trees. Fiber solves this by:

  • Splitting updates into small units βœ‚οΈ
  • Prioritizing important updates (animations vs background tasks) 🎯
  • Pausing, aborting, or resuming work for smooth UIs πŸ›‘βž‘οΈβ–ΆοΈ

Example Fiber Tree:

App
β”œβ”€ Header
β”‚  └─ Logo
β”œβ”€ Content
β”‚  β”œβ”€ Article
β”‚  └─ Sidebar
└─ Footer
Enter fullscreen mode Exit fullscreen mode

Each node is a Fiber Node, with links to parent, child, and sibling Fibers πŸ”—.


πŸ”Ή Virtual DOM vs Fiber: Key Differences βš”οΈ

Feature Virtual DOM πŸ–ΌοΈ Fiber Node πŸ”—
Purpose Represents UI in memory Unit of work for incremental rendering
Updates Synchronous diff & patch Can be split, prioritized, paused, resumed
Performance Reduces unnecessary DOM updates Optimizes updates with scheduling ⚑
Data Stored Tree of React elements Props, state, effect tags, pointers
Granularity Whole tree diff Node-level, fine-grained control 🧩

πŸ”Ή TL;DR Story πŸ“–

I once faced a laggy React app 🐌 with heavy nested components. Using just the Virtual DOM was fine for small apps, but with hundreds of updates, the UI stuttered. Fiber’s incremental reconciliation saved the day πŸŽ‰, letting React pause low-priority updates and keep animations smooth.


πŸ”Ή Conclusion βœ…

  • Virtual DOM πŸ–ΌοΈ: Represents what the UI should look like at a given moment. It’s just a snapshot of the UIβ€”no knowledge of how to update it incrementally.

  • Fiber Node πŸ”—:Is a unit of work associated with a VDOM node. It keeps track of state, props, effects, and links to parent/child/sibling nodes, and tells React how, when, and in what order to update the real DOM.

  • Together: VDOM calculates changes β†’ Fiber schedules updates efficiently ⚑

This duo is why React can remain both declarative and high-performance, even in large apps.


Author: Yogesh Bamanier
LinkedIn: https://www.linkedin.com/in/yogesh-007/

Top comments (0)