MCPcopy Index your code
hub / github.com/TanStack/table / Table

Function Table

examples/react/sub-components/src/main.tsx:106–178  ·  view source on GitHub ↗
({
  data,
  columns,
  renderSubComponent,
  getRowCanExpand,
}: TableProps<Person>)

Source from the content-addressed store, hash-verified

104}
105
106function Table({
107 data,
108 columns,
109 renderSubComponent,
110 getRowCanExpand,
111}: TableProps<Person>): JSX.Element {
112 const table = useReactTable<Person>({
113 data,
114 columns,
115 getRowCanExpand,
116 getCoreRowModel: getCoreRowModel(),
117 getExpandedRowModel: getExpandedRowModel(),
118 })
119
120 return (
121 <div className="p-2">
122 <div className="h-2" />
123 <table>
124 <thead>
125 {table.getHeaderGroups().map(headerGroup => (
126 <tr key={headerGroup.id}>
127 {headerGroup.headers.map(header => {
128 return (
129 <th key={header.id} colSpan={header.colSpan}>
130 {header.isPlaceholder ? null : (
131 <div>
132 {flexRender(
133 header.column.columnDef.header,
134 header.getContext()
135 )}
136 </div>
137 )}
138 </th>
139 )
140 })}
141 </tr>
142 ))}
143 </thead>
144 <tbody>
145 {table.getRowModel().rows.map(row => {
146 return (
147 <Fragment key={row.id}>
148 <tr>
149 {/* first row is a normal row */}
150 {row.getVisibleCells().map(cell => {
151 return (
152 <td key={cell.id}>
153 {flexRender(
154 cell.column.columnDef.cell,
155 cell.getContext()
156 )}
157 </td>
158 )
159 })}
160 </tr>
161 {row.getIsExpanded() && (
162 <tr>
163 {/* 2nd row is a custom 1 cell row */}

Callers

nothing calls this directly

Calls 6

useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getExpandedRowModelFunction · 0.85
renderSubComponentFunction · 0.85
getContextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…