Rules
no-key-after-spread
Prevent patterns that cause deoptimization when using the automatic JSX runtime.
Full Name in eslint-plugin-react-jsx
react-jsx/no-key-after-spreadFull Name in @eslint-react/eslint-plugin
@eslint-react/jsx/no-key-after-spreadPresets
recommended
recommended-typescript
recommended-type-checked
strict
strict-typescript
strict-type-checked
Rule Details
When using the JSX automatic runtime, key is a special prop in the JSX transform. See the Babel REPL and the TypeScript Playground.
If the key prop is before any spread props, it is passed as the key argument of the _jsx / _jsxs / _jsxDev function. But if the key prop is after spread props, the compiler uses createElement instead and passes key as a regular prop.
Common Violations
Invalid
<div {...props} key="2" />;
// ^^^ The 'key' prop must be placed before any spread props when using the new JSX transform.Valid
<div key="1" {...props} />;
<div key="3" className="" />;
<div className="" key="3" />;