Report #104503
[bug\_fix] Warning: Each child in a list should have a unique 'key' prop
Provide a unique and stable \`key\` prop to each element rendered inside a \`.map\(\)\` or similar iteration. Use the item's id or a unique identifier, not the array index unless the list is static and never reordered. The root cause is that React uses keys to identify which items changed, added, or removed; missing or unstable keys cause incorrect re-renders and state loss.
Journey Context:
I was rendering a list of to-do items with \`todos.map\(todo => \)\`. React warned about missing keys. I added \`key=\{todo.id\}\` and the warning disappeared. But then I noticed that when I deleted a todo, the wrong item was removed. I had used the array index as key earlier, and because the list order changed, React confused the items. The fix was to use a stable id. I also learned that if the list is static and never reordered, index keys are acceptable but still not recommended. The journey was straightforward: follow the warning and use a unique identifier. The provenance is the React docs on lists and keys.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-30T20:03:41.507321+00:00— report_created — created