You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are generating a heap of warnings when running in dev mode.
I understand the intention to try to avoid unintentional overwriting of a separate supplied key, but is the intention honestly to say you can no longer supply keys externally whatsoever?
React version: 18.2.0
Steps To Reproduce
Run the sample above.
The current behavior
Generates the following warning in development mode:
react_jsx-dev-runtime.js:92 Warning: A props object containing a "key" prop is being spread into JSX:
let props = {key: someKey, style: ..., children: ...};
<div {...props} />
React keys must be passed directly to JSX without using spread:
let props = {style: ..., children: ...};
<div key={someKey} {...props} />
at ComponentArray
The expected behavior
No warning should be generated - there is no other JSX key property being passed that might cause a collision here.
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
The added warning is part of reactjs/rfcs#107. We want to be able to statically extract the key so that we don't have to do it at runtime (which is costly considering the hot path JSX element creation is in). That is only possible if key is not spread.
This warning: https://github.com/facebook/react/blame/190cc990e01e5131a6b26f1a3212444cebd794e2/packages/react/src/jsx/ReactJSXElement.js#L530
Is triggering any time a rest-spread operator passes a key in an array.
That means even intentional and valid situations like:
Are generating a heap of warnings when running in dev mode.
I understand the intention to try to avoid unintentional overwriting of a separate supplied key, but is the intention honestly to say you can no longer supply keys externally whatsoever?
React version: 18.2.0
Steps To Reproduce
Run the sample above.
The current behavior
Generates the following warning in development mode:
The expected behavior
No warning should be generated - there is no other JSX key property being passed that might cause a collision here.
The text was updated successfully, but these errors were encountered: