import {Column, flexRender, getCoreRowModel, getSortedRowModel, useReactTable} from "@tanstack/react-table"; export default function List({data, columns}: {data: T[]; columns: any[]}) { const table = useReactTable({ data, columns: columns, getCoreRowModel: getCoreRowModel(), getSortedRowModel: getSortedRowModel(), }); return ( {table.getHeaderGroups().map((headerGroup) => ( {headerGroup.headers.map((header) => ( ))} ))} {table.getRowModel().rows.map((row) => ( {row.getVisibleCells().map((cell) => ( ))} ))}
{header.isPlaceholder ? null : ( <>
{flexRender(header.column.columnDef.header, header.getContext())} {{ asc: " 🔼", desc: " 🔽", }[header.column.getIsSorted() as string] ?? null}
)}
{flexRender(cell.column.columnDef.cell, cell.getContext())}
); }