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

Function App

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

Source from the content-addressed store, hash-verified

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