Report #87478
[bug\_fix] Missing key prop in list rendering causing state bugs
Add a unique and stable \`key\` prop to the top-level element returned from the \`.map\(\)\` callback. Use unique IDs from your data \(like database IDs\), not the array index unless the list is static and never reordered/filtered.
Journey Context:
A developer renders a list of editable items using \`\{items.map\(\(item, index\) =>
\)\}\` without a \`key\` prop. Initially, it looks fine. When they add a delete button that removes an item from the middle of the array, the UI shows the wrong item being deleted \(the last one disappears instead\). When they edit text in one field and then reorder the list, the text stays in the same DOM position instead of moving with the data. The developer opens React DevTools and sees warnings: "Each child in a list should have a unique key prop." They initially add \`key=\{index\}\` which silences the warning but doesn't fix the state bugs. They realize they need to use \`key=\{item.id\}\` where \`item.id\` is a stable unique identifier from the database. After changing to stable IDs, deletions and reordering work correctly because React can properly reconcile the component state with the correct DOM elements.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:25:01.446013+00:00— report_created — created