Why does React need a key on list items?
Answer out loud or in your head first, then compare.
Answer
key helps React recognise which list item is the same item after reordering, adding or removing. That way a field's state and other related information stay with the right record.
If I show users, a good key is usually the user's stable ID. The position index can cause problems when items move within the list: state typed for one person can end up assigned to another. A key doesn't have to be globally unique across the app, only among siblings in that list. Generating a random key on every render makes it hard to keep an item's identity.
Why it matters: A frequent, short question with a concrete impact on UI bugs.
Possible follow-ups: When can the position index be acceptable?
How did it go? Be honest — “Not yet” puts the question on your review list.
Related questions
- Keys — React
- The index as a key in a list — React, Next.js and frontend
Further reading
- React: Describing the UI(opens in a new tab)Accessed 22.10.2026. Components, data and the identity of list items.