New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule idea: jsx-unique-key
#2614
Comments
That seems like something |
The first example shouldn't warn because |
I'm going to solve this by adding a |
I think any HTML sibling nodes can be affected by |
@silverwind can you provide a react codesandbox that illustrates such a problem? if so, I can try to include it in the warnOnDuplicates option prior to release. |
I think the worst that can happen with non-array cases is unnecessary re-renders. That said, React does warn at runtime for the first example I provided above.
React docs say:
|
Ok thanks, I’ll reopen this then to cover the first case with the new option. |
@ljharb: Since f51ec45, The code that it trips on: https://github.com/microsoft/rnx-kit/blob/main/packages/test-app/src/App.native.tsx#L39 |
It triggers now on all elements inside my React app - also on elements that are not in an array. |
With this, I have now 7195 new lint errors for things that are completely not related to an array that never tripped before. For example:
Causes:
|
@stefcameron yes, thank you. that's #3215. |
I'd like to propose a rule that triggers when duplicate
key
properties are defined in on the same JSX nesting level or in arrays containing JSX at the top-level element.React depends on unique keys and will render very unexpected results when duplicate keys are present which shoult to my knowledge almost never be intentional.
Examples where the rule would trigger an error:
The text was updated successfully, but these errors were encountered: