()
| 14 | import './index.css' |
| 15 | |
| 16 | function ReactTableVirtualized() { |
| 17 | const [sorting, setSorting] = React.useState<SortingState>([]) |
| 18 | |
| 19 | const columns = React.useMemo<Array<ColumnDef<Person>>>( |
| 20 | () => [ |
| 21 | { |
| 22 | accessorKey: 'id', |
| 23 | header: 'ID', |
| 24 | size: 60, |
| 25 | }, |
| 26 | { |
| 27 | accessorKey: 'firstName', |
| 28 | cell: (info) => info.getValue(), |
| 29 | }, |
| 30 | { |
| 31 | accessorFn: (row) => row.lastName, |
| 32 | id: 'lastName', |
| 33 | cell: (info) => info.getValue(), |
| 34 | header: () => <span>Last Name</span>, |
| 35 | }, |
| 36 | { |
| 37 | accessorKey: 'age', |
| 38 | header: () => 'Age', |
| 39 | size: 50, |
| 40 | }, |
| 41 | { |
| 42 | accessorKey: 'visits', |
| 43 | header: () => <span>Visits</span>, |
| 44 | size: 50, |
| 45 | }, |
| 46 | { |
| 47 | accessorKey: 'status', |
| 48 | header: 'Status', |
| 49 | }, |
| 50 | { |
| 51 | accessorKey: 'progress', |
| 52 | header: 'Profile Progress', |
| 53 | size: 80, |
| 54 | }, |
| 55 | { |
| 56 | accessorKey: 'createdAt', |
| 57 | header: 'Created At', |
| 58 | cell: (info) => info.getValue<Date>().toLocaleString(), |
| 59 | }, |
| 60 | ], |
| 61 | [], |
| 62 | ) |
| 63 | |
| 64 | const [data, setData] = React.useState(() => makeData(50_000)) |
| 65 | |
| 66 | const table = useReactTable({ |
| 67 | data, |
| 68 | columns, |
| 69 | state: { |
| 70 | sorting, |
| 71 | }, |
| 72 | onSortingChange: setSorting, |
| 73 | getCoreRowModel: getCoreRowModel(), |
nothing calls this directly
no test coverage detected