Skip to content

react/jsx-key Correctness

This rule is turned on by default.

What it does

Enforce key prop for elements in array

Example

Examples of incorrect code for this rule:

jsx
[1, 2, 3].map((x) => <App />);
[1, 2, 3]?.map((x) => <BabelEslintApp />);

Examples of correct code for this rule:

jsx
[1, 2, 3].map((x) => <App key={x} />);
[1, 2, 3]?.map((x) => <BabelEslintApp key={x} />);

References

Released under the MIT License.