()
| 18 | // This is a dynamic row height example, which is more complicated, but allows for a more realistic table. |
| 19 | // See https://tanstack.com/virtual/v3/docs/examples/react/table for a simpler fixed row height example. |
| 20 | function App() { |
| 21 | const columns = React.useMemo<Array<ColumnDef<Person>>>( |
| 22 | () => [ |
| 23 | { |
| 24 | accessorKey: 'id', |
| 25 | header: 'ID', |
| 26 | size: 60, |
| 27 | }, |
| 28 | { |
| 29 | accessorKey: 'firstName', |
| 30 | cell: info => info.getValue(), |
| 31 | }, |
| 32 | { |
| 33 | accessorFn: row => row.lastName, |
| 34 | id: 'lastName', |
| 35 | cell: info => info.getValue(), |
| 36 | header: () => <span>Last Name</span>, |
| 37 | }, |
| 38 | { |
| 39 | accessorKey: 'age', |
| 40 | header: () => 'Age', |
| 41 | size: 50, |
| 42 | }, |
| 43 | { |
| 44 | accessorKey: 'visits', |
| 45 | header: () => <span>Visits</span>, |
| 46 | size: 50, |
| 47 | }, |
| 48 | { |
| 49 | accessorKey: 'status', |
| 50 | header: 'Status', |
| 51 | }, |
| 52 | { |
| 53 | accessorKey: 'progress', |
| 54 | header: 'Profile Progress', |
| 55 | size: 80, |
| 56 | }, |
| 57 | { |
| 58 | accessorKey: 'createdAt', |
| 59 | header: 'Created At', |
| 60 | cell: info => info.getValue<Date>().toLocaleString(), |
| 61 | size: 250, |
| 62 | }, |
| 63 | ], |
| 64 | [] |
| 65 | ) |
| 66 | |
| 67 | const [data, _setData] = React.useState(() => makeData(50_000)) |
| 68 | |
| 69 | const refreshData = React.useCallback(() => { |
| 70 | _setData(makeData(50_000)) |
| 71 | }, []) |
| 72 | |
| 73 | // refresh data every 5 seconds |
| 74 | React.useEffect(() => { |
| 75 | const interval = setInterval(() => { |
| 76 | refreshData() |
| 77 | }, 5000) |
nothing calls this directly
no test coverage detected