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

Function Table

packages/react-table/tests/core/core.test.tsx:102–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100describe('core', () => {
101 it('renders a table with markup', () => {
102 const Table = () => {
103 const [data] = React.useState<Person[]>(() => [...defaultData])
104 const [columns] = React.useState<typeof defaultColumns>(() => [
105 ...defaultColumns,
106 ])
107 const [columnVisibility, setColumnVisibility] = React.useState({})
108
109 const rerender = React.useReducer(() => ({}), {})[1]
110
111 const table = useReactTable({
112 data,
113 columns,
114 onColumnVisibilityChange: setColumnVisibility,
115 state: {
116 columnVisibility,
117 },
118 getCoreRowModel: getCoreRowModel(),
119 // debug: true,
120 })
121
122 return (
123 <div className="p-2">
124 <table>
125 <thead>
126 {table.getHeaderGroups().map(headerGroup => (
127 <tr key={headerGroup.id}>
128 {headerGroup.headers.map(header => (
129 <th key={header.id} colSpan={header.colSpan}>
130 {header.isPlaceholder
131 ? null
132 : flexRender(
133 header.column.columnDef.header,
134 header.getContext()
135 )}
136 </th>
137 ))}
138 </tr>
139 ))}
140 </thead>
141 <tbody>
142 {table.getRowModel().rows.map(row => (
143 <tr key={row.id}>
144 {row.getVisibleCells().map(cell => (
145 <td key={cell.id}>
146 {flexRender(
147 cell.column.columnDef.cell,
148 cell.getContext()
149 )}
150 </td>
151 ))}
152 </tr>
153 ))}
154 </tbody>
155 <tfoot>
156 {table.getFooterGroups().map(footerGroup => (
157 <tr key={footerGroup.id}>
158 {footerGroup.headers.map(header => (
159 <th key={header.id} colSpan={header.colSpan}>

Callers

nothing calls this directly

Calls 5

useReactTableFunction · 0.90
getCoreRowModelFunction · 0.90
flexRenderFunction · 0.90
getContextMethod · 0.80
rerenderFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…