({
data,
columns,
renderSubComponent,
getRowCanExpand,
}: TableProps<Person>)
| 104 | } |
| 105 | |
| 106 | function 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 */} |
nothing calls this directly
no test coverage detected
searching dependent graphs…