react-table and react/jsx-key eslint rules #2647
Replies: 4 comments 10 replies
-
A dumb workaround for this is to destructure the key out of the cellProps and pass it manually to the div.
|
Beta Was this translation helpful? Give feedback.
-
The above solution works. Doing the header section of the table was a bit gnarly though, and inevitably someone will also be looking for it, so I will post what I have just painstakingly done:
Hope this helps! Tanner, update your docs for |
Beta Was this translation helpful? Give feedback.
-
If anyone runs into the same problem - here is the code for a fully destructured ESLint safe version of a basic
|
Beta Was this translation helpful? Give feedback.
-
If anyone makes it down this far, and both doesn't want to do all the destructuring, and doesn't already know this, you can just tell eslint to ignore the rule. There's a tiny trick in that eslint gets weird about where you can put the comment for ignoring a react/rule, jsx-eslint/eslint-plugin-react#2369 But if you just throw the following inside your jsx return, everything should work. {/* eslint-disable react/jsx-key */}
{/* the jsx key is provided in the .get*Props() spreads, but eslint doesn't believe you. I believe you. */} |
Beta Was this translation helpful? Give feedback.
-
How do I make react-table work better with react/jsx-key? Currently get*Props supply the key which means eslint complains about missing key in loop, even though the key is actually supplied by react-table.
Beta Was this translation helpful? Give feedback.
All reactions