What is the purpose of React's key prop and index key risks?

This tests React reconciliation. Keys give stable identity to match components across renders and preserve state. Indices break on reorder or delete, causing state bugs. A red flag: saying keys are only for performance or indices are harmless.
This tests whether you understand React reconciliation and component identity beyond surface-level syntax. A strong answer explains that keys provide stable identity so React can match components across renders, preserve local state and DOM state like focus, and diff efficiently. Using array indices as keys causes serious bugs when items reorder, insert, or delete because React associates state with the wrong item or re-mounts unnecessarily.
Read the original → react.dev
- #react
- #reconciliation
- #keys
- #intermediate
- #frontend
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.