Skip to content

/errors/react/each-child-unique-key-prop

Each child in a list should have a unique "key" prop

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated 2026-10-20
tool
React
exit code
0
versions
React 16 – 19
os
any

React prints Each child in a list should have a unique "key" prop. in development when you render an array of elements, typically from items.map(...), and the elements have no key. React uses keys to match list items between renders; without them it falls back to positions, which breaks state and focus when items are added, removed or reordered.

Reproduce the warning

React 19 in Node.js, development build:

bash
npm init -y >/dev/null
npm install --silent --no-audit --no-fund react@19 react-dom@19 >/dev/null 2>&1
node -e '
const React = require("react");
const { renderToString } = require("react-dom/server");
const List = () => React.createElement("ul", null, ["a", "b"].map((x) => React.createElement("li", null, x)));
console.log(renderToString(React.createElement(List)));' 2>&1

Output

Each child in a list should have a unique "key" prop.

Check the render method of `List`. See https://react.dev/link/warning-keys for more information.
<ul><li>a</li><li>b</li></ul>

The warning names the component (Check the render method of List), which tells you which map() to fix.

Fix: a stable key from the data

jsx
function TodoList({ todos }) {
  return (
    <ul>
      {todos.map((todo) => (
        <li key={todo.id}>{todo.text}</li>
      ))}
    </ul>
  );
}

With fragments, the short syntax cannot take a key; use Fragment:

jsx
import { Fragment } from 'react';

{items.map((item) => (
  <Fragment key={item.id}>
    <dt>{item.term}</dt>
    <dd>{item.definition}</dd>
  </Fragment>
))}

Sources