React Fiber Reconciliation - the Diffing Algorithm
How React decides what to update and what to leave alone
When we talk about React performance, two terms always come up: Fiber reconciliation and the diffing algorithm. Understanding how these work gives you a much clearer picture of why React feels fast and how it avoids unnecessary DOM updates.
What is Diffing?
Diffing is the algorithm React uses to compare the previous Virtual DOM with the new Virtual DOM.
The goal is simple but powerful:
Detect which parts of the UI have changed and calculate the minimum updates required for the real (original) DOM.
Instead of updating the entire DOM on every change, React figures out exactly what changed and updates only those parts.
How React Compares Virtual DOM Trees
React compares:
During this comparison, React decides:
Two Common Cases During Reconciliation
During diffing, React mainly encounters two types of changes:
Element change at the same level
If an element changes at the same level of the tree:
This is why changing element types (for example, <div> → <section>) can be expensive.
Props change at the same level
If the element type is the same but props change:
This is the most efficient and common case.
Example Scenario: Overlay on a Component
Assume we have three components:
Component B displays a modal using an overlay.
Initial state: The overlay is visible.
State Change Happens
Now, the overlay status is set to false.
What happens next?
Fiber Diffing & Preparing the Commit
React Fiber now steps in:
This phase is where React decides the minimum set of DOM operations needed.
Commit Phase: Updating the Real DOM
Finally, based on the reconciliation result:
This is why React applications scale well even as the UI becomes complex.
Final Thoughts
React Fiber and the diffing algorithm are the backbone of React’s performance model. They allow React to:
If you understand this process, concepts like memo, useCallback, and key usage suddenly make a lot more sense.