Reconciliation is the process of comparing old and new Virtual DOM and applying minimal changes to the real DOM.
Simple analogy: Imagine you have a shopping list on the fridge (old Virtual DOM). You decided to update the list (new Virtual DOM). Instead of throwing away the entire list and writing a new one, you:
How React compares:
Comparison by element type:
<div> → <span> → React removes old element and creates new one (with all children).<div> → <div> → React updates props and recursively compares children.Comparison by keys:
key={index} — if the list is re-sorted, React redraws everything.key={item.id} — React knows exactly which element moved where.Optimization:
Important: Reconciliation is the reason why you need to specify key for lists and not change element type without necessity.