()
| 75 | |
| 76 | // Table Component |
| 77 | function App() { |
| 78 | const columns = React.useMemo<ColumnDef<Person>[]>( |
| 79 | () => [ |
| 80 | // Create a dedicated drag handle column. Alternatively, you could just set up dnd events on the rows themselves. |
| 81 | { |
| 82 | id: 'drag-handle', |
| 83 | header: 'Move', |
| 84 | cell: ({ row }) => <RowDragHandleCell rowId={row.id} />, |
| 85 | size: 60, |
| 86 | }, |
| 87 | { |
| 88 | accessorKey: 'firstName', |
| 89 | cell: info => info.getValue(), |
| 90 | }, |
| 91 | { |
| 92 | accessorFn: row => row.lastName, |
| 93 | id: 'lastName', |
| 94 | cell: info => info.getValue(), |
| 95 | header: () => <span>Last Name</span>, |
| 96 | }, |
| 97 | { |
| 98 | accessorKey: 'age', |
| 99 | header: () => 'Age', |
| 100 | }, |
| 101 | { |
| 102 | accessorKey: 'visits', |
| 103 | header: () => <span>Visits</span>, |
| 104 | }, |
| 105 | { |
| 106 | accessorKey: 'status', |
| 107 | header: 'Status', |
| 108 | }, |
| 109 | { |
| 110 | accessorKey: 'progress', |
| 111 | header: 'Profile Progress', |
| 112 | }, |
| 113 | ], |
| 114 | [] |
| 115 | ) |
| 116 | const [data, setData] = React.useState(() => makeData(20)) |
| 117 | |
| 118 | const dataIds = React.useMemo<UniqueIdentifier[]>( |
| 119 | () => data?.map(({ userId }) => userId), |
| 120 | [data] |
| 121 | ) |
| 122 | |
| 123 | const rerender = () => setData(() => makeData(20)) |
| 124 | |
| 125 | const table = useReactTable({ |
| 126 | data, |
| 127 | columns, |
| 128 | getCoreRowModel: getCoreRowModel(), |
| 129 | getRowId: row => row.userId, //required because row indexes will change |
| 130 | debugTable: true, |
| 131 | debugHeaders: true, |
| 132 | debugColumns: true, |
| 133 | }) |
| 134 |
nothing calls this directly
no test coverage detected