()
| 17 | import { makeData, Person } from './makeData' |
| 18 | |
| 19 | function App() { |
| 20 | const rerender = React.useReducer(() => ({}), {})[1] |
| 21 | |
| 22 | const columns = React.useMemo<ColumnDef<Person>[]>( |
| 23 | () => [ |
| 24 | { |
| 25 | header: 'Name', |
| 26 | columns: [ |
| 27 | { |
| 28 | accessorKey: 'firstName', |
| 29 | header: 'First Name', |
| 30 | cell: info => info.getValue(), |
| 31 | /** |
| 32 | * override the value used for row grouping |
| 33 | * (otherwise, defaults to the value derived from accessorKey / accessorFn) |
| 34 | */ |
| 35 | getGroupingValue: row => `${row.firstName} ${row.lastName}`, |
| 36 | }, |
| 37 | { |
| 38 | accessorFn: row => row.lastName, |
| 39 | id: 'lastName', |
| 40 | header: () => <span>Last Name</span>, |
| 41 | cell: info => info.getValue(), |
| 42 | }, |
| 43 | ], |
| 44 | }, |
| 45 | { |
| 46 | header: 'Info', |
| 47 | columns: [ |
| 48 | { |
| 49 | accessorKey: 'age', |
| 50 | header: () => 'Age', |
| 51 | aggregatedCell: ({ getValue }) => |
| 52 | Math.round(getValue<number>() * 100) / 100, |
| 53 | aggregationFn: 'median', |
| 54 | }, |
| 55 | { |
| 56 | header: 'More Info', |
| 57 | columns: [ |
| 58 | { |
| 59 | accessorKey: 'visits', |
| 60 | header: () => <span>Visits</span>, |
| 61 | aggregationFn: 'sum', |
| 62 | // aggregatedCell: ({ getValue }) => getValue().toLocaleString(), |
| 63 | }, |
| 64 | { |
| 65 | accessorKey: 'status', |
| 66 | header: 'Status', |
| 67 | }, |
| 68 | { |
| 69 | accessorKey: 'progress', |
| 70 | header: 'Profile Progress', |
| 71 | cell: ({ getValue }) => |
| 72 | Math.round(getValue<number>() * 100) / 100 + '%', |
| 73 | aggregationFn: 'mean', |
| 74 | aggregatedCell: ({ getValue }) => |
| 75 | Math.round(getValue<number>() * 100) / 100 + '%', |
| 76 | }, |
nothing calls this directly
no test coverage detected