React logs that a props object with a key is spread into JSX
Fix it fast
Most common cause, 1 of 2Your own data object has a field called key
Split key off before the spread and give it to the element on its own.
{rows.map((row) => {
const { key, ...rest } = row;
return <ListItem key={key} rowId={key} {...rest} />;
})}Short answer
A props object containing a "key" prop is being spread into JSX is a development message from React's JSX runtime: an object passed with {...props} carries a key field. Pull it out first with const { key, ...rest } = props, then render <Item key={key} {...rest} />. Seen in React 18.3 and 19.3; production builds do not print it.
Which cause do you have?
Read the two example lines in the message. The tag in <Name {...props} /> is where the spread happens, and the field list after key: someKey shows what the object holds. Search your code for spreads into that tag; no hit means the spread sits inside a package.
grep -rnE "<ListItem[^>]*\{\.\.\." src/Then find the line you see in this list and open its fix:
- 1Your own data object has a field called key
The field list shows your own names, such as key: someKey, title: ..., price: ..., and the tag is one of your components - 2A library callback hands you props that include key
The field list holds attributes and handlers you never wrote, such as role, aria-* fields, className and onClick
What does the error look like?
A props object containing a "key" prop is being spread into JSX:React keys must be passed directly to JSX without using spread:Warning: A props object containing a "key" prop is being spread into JSX:
Cause 1 of 2
Your own data object has a field called key
You seeThe field list shows your own names, such as key: someKey, title: ..., price: ..., and the tag is one of your components
Check
React prints the key spread message whenever the object given to a JSX tag through {...props} owns a key property. A record that stores key as an ordinary data field trips it as soon as the whole record is spread into a component.
grep -rnE "\{\.\.\.(item|row|record|props)\}" src/Fix
Split key off before the spread and give it to the element on its own. If the component also needs that value, pass it again under another name, since a component never receives key as a prop.
{rows.map((row) => {
const { key, ...rest } = row;
return <ListItem key={key} rowId={key} {...rest} />;
})}Verify
Reload the page in development with the console open. The message is gone and the list renders as before.
npm run devConfirmed by raw.githubusercontent.com
Cause 2 of 2
A library callback hands you props that include key
You seeThe field list holds attributes and handlers you never wrote, such as role, aria-* fields, className and onClick
Check
Some component APIs pass a ready-made props object into your render callback, and that object already includes key. MUI's Autocomplete renderOption is one such API: its demos take key off the first argument before spreading the rest onto an li.
grep -rn "renderOption" src/Fix
Inside the callback, separate key from the rest the way MUI's own demos do, then set key on the returned element and spread only the remainder.
renderOption={(props, option) => {
const { key, ...optionProps } = props;
return (
<li key={key} {...optionProps}>
{option.label}
</li>
);
}}Verify
Open the dropdown again. The options render and the console stays clean.
npm run devConfirmed by raw.githubusercontent.com
How do I stop it coming back?
- Rename key fields to id when you shape API data for the UI, so whole records can be spread safely.
- When a library gives you a props object in a callback, always destructure key out of it before spreading.
- Keep the browser console visible during development and treat this message as a bug to fix, not noise.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, QistLock, Taskvare.