-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
(react/jsx-key) still warns when wrapping with React.Children.toArray #1574
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
Comments
React.Children.toArray
jsx-key rule should always succeed if we're inside React.Children.toArray() because omitting the key there doesn't cause a React warning. Fixes jsx-eslint#1574.
No idea, my guess is that it's worked that way forever (ever since that API was introduced). |
As long as React 0.13 also didn't warn, then I think we're good :-) otherwise we'd need to warn on older React versions. |
Did some quick testing, going back to 0.14.0 it still doesn't warn: https://codesandbox.io/s/92rp6893po |
And it seems like toArray didn't exist on React.Children in 0.13.0. |
Is this still a thing after 5 years? If not, what's the solution? |
@MatPayette not sure, you can easily check, and if it's still an issue you can try continuing my PR #1591 based on the comments. 🙂 |
jsx-key rule should always succeed if we're inside React.Children.toArray() because omitting the key there doesn't cause a React warning. Fixes jsx-eslint#1574.
jsx-key rule should always succeed if we're inside React.Children.toArray() because omitting the key there doesn't cause a React warning. Fixes jsx-eslint#1574.
The (react/jsx-key) rule seems to still warn for instances wrapped with the
React.Children.toArray
utility.This seems to be a bug since React no longer warns about missing keys when wrapping and considers it valid (the toArray utility provides keys to each item automatically)
Suggested Solution:
The rule accounts for instances wrapped with
React.Children.toArray
correctly and does not warn.Edit:
I incorrectly described this as the no-array-index (as key) rule from this eslint plugin, but it is actually:
[eslint] Missing "key" prop for element in iterator (react/jsx-key)
. Updated the body of the issue plus the title to reflect the correct rule.The text was updated successfully, but these errors were encountered: