While using the setSortBy function. It is showing the below error "setSortBy is not a function".
How im accesssing setSortBy:
const { getTableProps, getTableBodyProps, headerGroups, rows, setSortBy, } = useTable( { columns, data, defaultColumn, initialState: { pageIndex: 0 }, }, usePagination, useBlockLayout, useResizeColumns );
How im using: <span onClick={() => setSortBy([{ id: column.id, desc: false }])}> <span onClick={() => setSortBy([{ id: column.id, desc: true }])}>
It is because, you need to include useSortBy in your useTable like this
without including this useSortBy, you cannot able to destructure setSortBy from useTable