T
TanStack15mo ago
optimistic-gold

onSortingChange: undefined gives a manual sorted table

Hi! I have a custom Table component that I would like to use for tables with and without manual sorting. I expected that this would give me a table without manual sorting
manualSorting: false,
onSortingChange: undefined
state: undefined,
manualSorting: false,
onSortingChange: undefined
state: undefined,
state: undefined works, but setting onSortingChange: undefined does not work as I expected, I stil get a manual sorted table. How can I get around this? My customTable component:
function Table<T>({ data, columns, sorting, onRowClicked, onSortingChange, manualSorting }: Readonly<TableProps<T>>) {


const table = useReactTable({
columns: columns,
data: data,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
manualSorting: manualSorting,
onSortingChange: manualSorting ? onSortingChange : undefined,
state: manualSorting
? {
sorting,
}
: undefined,
});
return (//Styled table here)
function Table<T>({ data, columns, sorting, onRowClicked, onSortingChange, manualSorting }: Readonly<TableProps<T>>) {


const table = useReactTable({
columns: columns,
data: data,
getCoreRowModel: getCoreRowModel(),
getSortedRowModel: getSortedRowModel(),
manualSorting: manualSorting,
onSortingChange: manualSorting ? onSortingChange : undefined,
state: manualSorting
? {
sorting,
}
: undefined,
});
return (//Styled table here)
All mye tables have the same styling which is why I would like to use the same custom Table component on both manual and non-manual sorted tables.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?