@@ -4,6 +4,7 @@ import ReactDOM from 'react-dom/client'
44import './index.css'
55
66import {
7+ ColumnDef ,
78 ColumnFiltering ,
89 ColumnGrouping ,
910 RowExpanding ,
@@ -23,74 +24,76 @@ import type { GroupingState } from '@tanstack/react-table'
2324import type { Person } from './makeData'
2425
2526const tableHelper = createTableHelper ( {
26- features : {
27+ _features : {
2728 ColumnFiltering,
2829 RowPagination,
2930 RowSorting,
3031 ColumnGrouping,
3132 RowExpanding,
3233 } ,
33- rowModels : {
34+ _rowModels : {
3435 Core : createCoreRowModel ( ) ,
3536 Filtered : createFilteredRowModel ( ) ,
3637 Paginated : createPaginatedRowModel ( ) ,
3738 Sorted : createSortedRowModel ( ) ,
3839 Grouped : createGroupedRowModel ( ) ,
3940 Expanded : createExpandedRowModel ( ) ,
4041 } ,
42+ TData : { } as Person ,
4143} )
4244
4345function App ( ) {
4446 const rerender = React . useReducer ( ( ) => ( { } ) , { } ) [ 1 ]
4547
46- const columns = React . useMemo (
47- ( ) =>
48- tableHelper . columnHelper . columns < typeof tableHelper . features , Person > ( [
49- {
50- accessorKey : 'firstName' ,
51- header : 'First Name' ,
52- cell : ( info ) => info . getValue ( ) ,
53- /**
54- * override the value used for row grouping
55- * (otherwise, defaults to the value derived from accessorKey / accessorFn)
56- */
57- getGroupingValue : ( row ) => `${ row . firstName } ${ row . lastName } ` ,
58- } ,
59- {
60- accessorFn : ( row ) => row . lastName ,
61- id : 'lastName' ,
62- header : ( ) => < span > Last Name</ span > ,
63- cell : ( info ) => info . getValue ( ) ,
64- } ,
48+ const columns = React . useMemo <
49+ Array < ColumnDef < typeof tableHelper . features , Person > >
50+ > (
51+ ( ) => [
52+ {
53+ accessorKey : 'firstName' ,
54+ header : 'First Name' ,
55+ cell : ( info ) => info . getValue ( ) ,
56+ /**
57+ * override the value used for row grouping
58+ * (otherwise, defaults to the value derived from accessorKey / accessorFn)
59+ */
60+ getGroupingValue : ( row ) => `${ row . firstName } ${ row . lastName } ` ,
61+ } ,
62+ {
63+ accessorFn : ( row ) => row . lastName ,
64+ id : 'lastName' ,
65+ header : ( ) => < span > Last Name</ span > ,
66+ cell : ( info ) => info . getValue ( ) ,
67+ } ,
6568
66- {
67- accessorKey : 'age' ,
68- header : ( ) => 'Age' ,
69- aggregatedCell : ( { getValue } ) =>
70- Math . round ( getValue < number > ( ) * 100 ) / 100 ,
71- aggregationFn : 'median' ,
72- } ,
69+ {
70+ accessorKey : 'age' ,
71+ header : ( ) => 'Age' ,
72+ aggregatedCell : ( { getValue } ) =>
73+ Math . round ( getValue < number > ( ) * 100 ) / 100 ,
74+ aggregationFn : 'median' ,
75+ } ,
7376
74- {
75- accessorKey : 'visits' ,
76- header : ( ) => < span > Visits</ span > ,
77- aggregationFn : 'sum' ,
78- // aggregatedCell: ({ getValue }) => getValue().toLocaleString(),
79- } ,
80- {
81- accessorKey : 'status' ,
82- header : 'Status' ,
83- } ,
84- {
85- accessorKey : 'progress' ,
86- header : 'Profile Progress' ,
87- cell : ( { getValue } ) =>
88- Math . round ( getValue < number > ( ) * 100 ) / 100 + '%' ,
89- aggregationFn : 'mean' ,
90- aggregatedCell : ( { getValue } ) =>
91- Math . round ( getValue < number > ( ) * 100 ) / 100 + '%' ,
92- } ,
93- ] ) ,
77+ {
78+ accessorKey : 'visits' ,
79+ header : ( ) => < span > Visits</ span > ,
80+ aggregationFn : 'sum' ,
81+ // aggregatedCell: ({ getValue }) => getValue().toLocaleString(),
82+ } ,
83+ {
84+ accessorKey : 'status' ,
85+ header : 'Status' ,
86+ } ,
87+ {
88+ accessorKey : 'progress' ,
89+ header : 'Profile Progress' ,
90+ cell : ( { getValue } ) =>
91+ Math . round ( getValue < number > ( ) * 100 ) / 100 + '%' ,
92+ aggregationFn : 'mean' ,
93+ aggregatedCell : ( { getValue } ) =>
94+ Math . round ( getValue < number > ( ) * 100 ) / 100 + '%' ,
95+ } ,
96+ ] ,
9497 [ ] ,
9598 )
9699
0 commit comments