MCPcopy
hub / github.com/TanStack/table / App

Function App

examples/react/custom-features/src/main.tsx:123–337  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121
122//app code
123function App() {
124 const columns = React.useMemo<ColumnDef<Person>[]>(
125 () => [
126 {
127 accessorKey: 'firstName',
128 cell: info => info.getValue(),
129 footer: props => props.column.id,
130 },
131 {
132 accessorFn: row => row.lastName,
133 id: 'lastName',
134 cell: info => info.getValue(),
135 header: () => <span>Last Name</span>,
136 footer: props => props.column.id,
137 },
138 {
139 accessorKey: 'age',
140 header: () => 'Age',
141 footer: props => props.column.id,
142 },
143 {
144 accessorKey: 'visits',
145 header: () => <span>Visits</span>,
146 footer: props => props.column.id,
147 },
148 {
149 accessorKey: 'status',
150 header: 'Status',
151 footer: props => props.column.id,
152 },
153 {
154 accessorKey: 'progress',
155 header: 'Profile Progress',
156 footer: props => props.column.id,
157 },
158 ],
159 []
160 )
161
162 const [data, _setData] = React.useState(() => makeData(1000))
163 const [density, setDensity] = React.useState<DensityState>('md')
164
165 const table = useReactTable({
166 _features: [DensityFeature], //pass our custom feature to the table to be instantiated upon creation
167 columns,
168 data,
169 debugTable: true,
170 getCoreRowModel: getCoreRowModel(),
171 getSortedRowModel: getSortedRowModel(),
172 getFilteredRowModel: getFilteredRowModel(),
173 getPaginationRowModel: getPaginationRowModel(),
174 state: {
175 density, //passing the density state to the table, TS is still happy :)
176 },
177 onDensityChange: setDensity, //using the new onDensityChange option, TS is still happy :)
178 })
179
180 return (

Callers

nothing calls this directly

Calls 10

makeDataFunction · 0.90
useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getSortedRowModelFunction · 0.85
getFilteredRowModelFunction · 0.85
getPaginationRowModelFunction · 0.85
getContextMethod · 0.80
previousPageMethod · 0.80
nextPageMethod · 0.80

Tested by

no test coverage detected