import { useReactTable, flexRender, getCoreRowModel } from '@tanstack/react-table'; import type { ColumnDef } from '@tanstack/react-table'; interface DataTableProps { columns: ColumnDef[]; data: TData[]; } export default function DataTable({ columns, data }: DataTableProps) { const table = useReactTable({ columns, data, getCoreRowModel: getCoreRowModel(), }); return ( {table.getHeaderGroups().map((headerGroup, i) => ( {headerGroup.headers.map((header, j) => ( ))} ))} {table.getRowModel().rows.map((row, i) => ( {row.getVisibleCells().map((cell, j) => ( ))} ))}
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
{flexRender(cell.column.columnDef.cell, cell.getContext())}
); }