react/jsx-key
eslint-plugin-react
No autofixRecommended
eslint.config.js
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-key": "error",
},
},
];[<Hello />, <Hello />, <Hello />];data.map(x => <Hello>{x}</Hello>);Array.from([1, 2, 3], (x) => <Hello>{x}</Hello>);[<Hello key="first" />, <Hello key="second" />, <Hello key="third" />];data.map((x) => <Hello key={x.id}>{x}</Hello>);Array.from([1, 2, 3], (x) => <Hello key={x}>{x}</Hello>);Examples from the ESLint documentation.
react/jsx-key
eslint-plugin-react
import react from "eslint-plugin-react";
export default [
{
plugins: { react },
rules: {
"react/jsx-key": "error",
},
},
];react/jsx-key
react plugin · correctness
{
"plugins": [
"react"
],
"rules": {
"react/jsx-key": "error"
}
}correctness/useJsxKeyInIterable
correctness · since 1.6.0
{
"linter": {
"rules": {
"correctness": {
"useJsxKeyInIterable": "error"
}
}
}
}Disallow usage of the return value of ReactDOM.render
Disallow passing of children as props
Enforce ES5 or ES6 class for returning value in render function