Report #101443
[bug\_fix] Warning: Each child in a list should have a unique "key" prop, causing lost state or extra re-mounts
Pass a stable, unique \`key\` prop to every element rendered inside \`.map\(\)\`. The key must be derived from the data \(e.g., item.id\), not the array index, unless the list is append-only and never reordered or filtered. If items have no stable ID, generate one when the data is created and store it in state or the database.
Journey Context:
A todo app lets users reorder items via drag-and-drop. After the drop, some checked todos appear unchecked and inputs lose focus. The console shows the key warning. The dev initially used \`key=\{index\}\`. When the array reorders, React sees the same keys in the same DOM positions and reuses components incorrectly, attaching the old state to the wrong items. Switching to \`key=\{todo.id\}\` fixes the state mapping because React now tracks each todo by its persistent identity across moves. They audit the codebase and find the same bug in a filtered table; there they add a stable UUID generated on the server for each row.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:51:35.733452+00:00— report_created — created