-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Description
Is there an existing issue for this?
- I have searched the existing issues and my issue is unique
- My issue appears in the command-line and not only in the text editor
Description Overview
react/jsx-key
is raised on arrays inline in JSX even if they're immediately consumed and not subject to reconciliation.
<>
{[
<p>a</p> // Missing "key" prop for element in array ESLint[react/jsx-key],
// ...
].map(
(text, i) => <div key={i}>{text}</div>
)}
</>
In this example, React doesn't need a key because on p
because it's the only child, right?
Here's a repro:
What is happening? / What is the error?
I see the warning where it's not needed.
What command(s) did you run to reproduce issue?
eslint
Expected Behavior
I'd expect the warning to appear only when the missing key causes a warning logged by React in development.
I can open a PR if it makes sense.
eslint-plugin-react version
v7.33.2
eslint version
v9.35.0
node version
v24