MCPcopy Create free account
hub / github.com/TanStack/table / App

Function App

examples/react/expanding/src/main.tsx:20–260  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18import { makeData, Person } from './makeData'
19
20function App() {
21 const rerender = React.useReducer(() => ({}), {})[1]
22
23 const columns = React.useMemo<ColumnDef<Person>[]>(
24 () => [
25 {
26 accessorKey: 'firstName',
27 header: ({ table }) => (
28 <>
29 <IndeterminateCheckbox
30 {...{
31 checked: table.getIsAllRowsSelected(),
32 indeterminate: table.getIsSomeRowsSelected(),
33 onChange: table.getToggleAllRowsSelectedHandler(),
34 }}
35 />{' '}
36 <button
37 {...{
38 onClick: table.getToggleAllRowsExpandedHandler(),
39 }}
40 >
41 {table.getIsAllRowsExpanded() ? '👇' : '👉'}
42 </button>{' '}
43 First Name
44 </>
45 ),
46 cell: ({ row, getValue }) => (
47 <div
48 style={{
49 // Since rows are flattened by default,
50 // we can use the row.depth property
51 // and paddingLeft to visually indicate the depth
52 // of the row
53 paddingLeft: `${row.depth * 2}rem`,
54 }}
55 >
56 <div>
57 <IndeterminateCheckbox
58 {...{
59 checked: row.getIsSelected(),
60 indeterminate: row.getIsSomeSelected(),
61 onChange: row.getToggleSelectedHandler(),
62 }}
63 />{' '}
64 {row.getCanExpand() ? (
65 <button
66 {...{
67 onClick: row.getToggleExpandedHandler(),
68 style: { cursor: 'pointer' },
69 }}
70 >
71 {row.getIsExpanded() ? '👇' : '👉'}
72 </button>
73 ) : (
74 '🔵'
75 )}{' '}
76 {getValue<boolean>()}
77 </div>

Callers

nothing calls this directly

Calls 12

makeDataFunction · 0.90
useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getPaginationRowModelFunction · 0.85
getFilteredRowModelFunction · 0.85
getExpandedRowModelFunction · 0.85
getContextMethod · 0.80
previousPageMethod · 0.80
nextPageMethod · 0.80
refreshDataFunction · 0.70
rerenderFunction · 0.50

Tested by

no test coverage detected