`react/display-name` and `react/prop-types` are incorrectly reported in `react-table`
See original GitHub issueFor this component:
import React from 'react';
import ReactTable from 'react-table';
import 'react-table/react-table.css';
function Test() {
const data = [
{
name: 'Bob',
},
];
const columns = [
{
Header: 'Name',
accessor: 'name',
Cell: ({ value }) => <div>{value}</div>,
},
];
return <ReactTable columns={columns} data={data} />;
}
export default Test;
The line: Cell: ({ value }) => <div>{value}</div>,
incorrectly reports the following two errors:
Component definition is missing display name. eslint(react/display-name)
'value' is missing in props validation. eslint(react/prop-types)
These two errors should not appear. There are, correctly, no errors, when the above code is converted to a class:
import React from 'react';
import ReactTable from 'react-table';
import 'react-table/react-table.css';
class Test {
render() {
const data = [
{
name: 'Bob',
},
];
const columns = [
{
Header: 'Name',
accessor: 'name',
Cell: ({ value }) => <div>{value}</div>,
},
];
return <ReactTable columns={columns} data={data} />;
}
}
export default Test;
Otherwise, is there a way I can avoid these errors, without disabling the rules?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
`react/display-name` and `react/prop-types` are incorrectly ...
For this component: import React from 'react'; import ReactTable ... react/display-name and react/prop-types are incorrectly reported in ...
Read more >`react/display-name` and `react/prop-types` are incorrectly reported ...
For this component: import React from 'react'; import ReactTable from 'react-table'; import 'react-table/react-table.css'; function Test() { const data ...
Read more >Something went wrong with react table using typescript
I have an typescript error when using react-table with useGlobalFilter. I just followed some instructions on internet. Here is my code:
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I tried the following, and it did indeed resolve
display-name
, but notprop-types
:No, you can use a normal named function instead of an arrow - components shouldn’t be arrow functions, ideally.