Frontend · interactive
Reconciliation and keys
When a list re-renders, React matches old and new items by key and reuses the matching DOM, including any state inside it. Use the array index as the key and inserting at the top shifts every match by one. These two lists are real React; try it.
key={index}
- Ada
- Bo
- Cy
key={item.id}
- Ada
- Bo
- Cy
Both lists look the same. Edit a note if you like, then insert Zoe at the top.
Each row keeps its note in its own useState, which React preserves by key.
Step 1 of 4 · read left to right
In production
Tools and technologies
Keys are how React matches list items between renders.
Not tied to one language — use these names when you search docs or design a system.