Answer
During reconciliation React compares the new element tree to the previous one:
- Different element types → tear down old subtree, mount new one.
- Same type, same key → update props in place, preserve state/DOM where possible.
- Lists → keys tell React which item moved vs was added/removed.
Anti-pattern: using array index as key when items can reorder, insert, or delete — causes wrong component state, skipped updates, and poor performance.