I've set up my React project with Typescript and React-Table. I was following the Quick Start Guide from the React-Table website and got an error.
const data = React.useMemo(
() => [
{
col1: 'Hello',
col2: 'World',
},
{
col1: 'react-table',
col2: 'rocks',
},
{
col1: 'whatever',
col2: 'you want',
},
],
[]
)
const columns = React.useMemo(
() => [
{
Header: 'Column 1',
accessor: 'col1', // accessor is the "key" in the data
},
{
Header: 'Column 2',
accessor: 'col2',
},
],
[]
)
I get an error when doing const tableInstance = useTable({ columns, data }).
Type '{ Header: string; accessor: string; }[]' is not assignable to type 'readonly Column<{ col1: string; col2: string; }>[]'. Type '{ Header: string; accessor: string; }' is not assignable to type 'Column<{ col1: string; col2: string; }>'.
I barely just started getting into this so I don't really know what's going on. Here is a code sandbox with a recreation of the problem: Sandbox