MCPcopy Index your code
hub / github.com/TanStack/table / App

Function App

examples/react/row-dnd/src/main.tsx:77–201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75
76// Table Component
77function 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

Callers

nothing calls this directly

Calls 6

makeDataFunction · 0.90
useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getContextMethod · 0.80
rerenderFunction · 0.70

Tested by

no test coverage detected