react · JavaScript
The message
Each child in a list should have a unique "key" prop.
What it means
Sibling elements rendered as a list have no key, so React cannot match them up with the same items on the next render. You built the elements with items.map(...) and left key out; it is only a warning, so the screen still draws, but it comes back as a quiet bug once the list changes — the symptom is an input value or an animation staying on the wrong row. Give it a stable id from your data. Using the array index as the key is safe only for a list whose order never changes and where nothing is inserted or removed in the middle; otherwise it reproduces almost exactly the problem of having no key at all. As of React 19 the leading Warning: is gone.
The fix
There is no one-line command for this. The explanation says what to look at instead.
- Printed by
- react
- JavaScript
- 15
Browser and Node errors usually tell you what broke and not why the value became what it was — you read undefined, it was not a function, it was not JSON — so the place to fix is upstream of the line that threw, and silencing just that line with ?. and default values makes the same problem reappear further away in a form that is harder to recognise.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “Each child in a list should have a unique "key" prop.” mean?
Sibling elements rendered as a list have no key, so React cannot match them up with the same items on the next render. You built the elements with items.map(...) and left key out; it is only a warning, so the screen still draws, but it comes back as a quiet bug once the list changes — the symptom is an input value or an animation staying on the wrong row. Give it a stable id from your data. Using the array index as the key is safe only for a list whose order never changes and where nothing is inserted or removed in the middle; otherwise it reproduces almost exactly the problem of having no key at all. As of React 19 the leading Warning: is gone.
Q. How do I fix it?
There is no one-line command. The explanation above says what to look at instead.
Q. Which tool prints this?
react. It sits under JavaScript, and the message runs to 11 words.