react-table에서 useTable이나 <Table />을 사용할 때 초기 sorting을 적용하려면 useSortBy를 사용하면 된다.
const { getTableProps, getTableBodyProps, headerGroups, prepareRow, rows } =
useTable(
{
columns,
data,
initialState: {
...,
sortBy: [
{
id: "sortedBy",
desc: true,
},
],
},
},
useSortBy
);
참고 자료