()
| 18 | |
| 19 | // All important CSS styles are included as inline styles for this example. This is not recommended for your code. |
| 20 | function App() { |
| 21 | const columns = React.useMemo<ColumnDef<Person>[]>( |
| 22 | () => makeColumns(1_000), |
| 23 | [] |
| 24 | ) |
| 25 | |
| 26 | const [data, setData] = React.useState(() => makeData(1_000, columns)) |
| 27 | |
| 28 | const refreshData = React.useCallback(() => { |
| 29 | setData(makeData(1_000, columns)) |
| 30 | }, [columns]) |
| 31 | |
| 32 | // refresh data every 5 seconds |
| 33 | React.useEffect(() => { |
| 34 | const interval = setInterval(() => { |
| 35 | refreshData() |
| 36 | }, 5000) |
| 37 | return () => clearInterval(interval) |
| 38 | }, [refreshData]) |
| 39 | |
| 40 | // The table does not live in the same scope as the virtualizers |
| 41 | const table = useReactTable({ |
| 42 | data, |
| 43 | columns, |
| 44 | getCoreRowModel: getCoreRowModel(), |
| 45 | getSortedRowModel: getSortedRowModel(), |
| 46 | debugTable: true, |
| 47 | }) |
| 48 | |
| 49 | return ( |
| 50 | <div className="app"> |
| 51 | {process.env.NODE_ENV === 'development' ? ( |
| 52 | <p> |
| 53 | <strong>Notice:</strong> You are currently running React in |
| 54 | development mode. Virtualized rendering performance will be slightly |
| 55 | degraded until this application is built for production. |
| 56 | </p> |
| 57 | ) : null} |
| 58 | <div>({columns.length.toLocaleString()} columns)</div> |
| 59 | <div>({data.length.toLocaleString()} rows)</div> |
| 60 | <button onClick={refreshData}>Refresh Data</button> |
| 61 | <TableContainer table={table} /> |
| 62 | </div> |
| 63 | ) |
| 64 | } |
| 65 | |
| 66 | interface TableContainerProps { |
| 67 | table: Table<Person> |
nothing calls this directly
no test coverage detected