({
row,
rowRefsMap,
rowVirtualizer,
virtualRowIndex,
}: TableBodyRowProps)
| 254 | } |
| 255 | |
| 256 | function TableBodyRow({ |
| 257 | row, |
| 258 | rowRefsMap, |
| 259 | rowVirtualizer, |
| 260 | virtualRowIndex, |
| 261 | }: TableBodyRowProps) { |
| 262 | return ( |
| 263 | <tr |
| 264 | data-index={virtualRowIndex} // needed for dynamic row height measurement |
| 265 | ref={node => { |
| 266 | if (node && virtualRowIndex) { |
| 267 | rowVirtualizer.measureElement(node) // measure dynamic row height |
| 268 | rowRefsMap.current.set(virtualRowIndex, node) // store ref for virtualizer to apply scrolling transforms |
| 269 | } |
| 270 | }} |
| 271 | key={row.id} |
| 272 | style={{ |
| 273 | display: 'flex', |
| 274 | position: 'absolute', |
| 275 | width: '100%', |
| 276 | }} |
| 277 | > |
| 278 | {row.getVisibleCells().map(cell => { |
| 279 | return ( |
| 280 | <td |
| 281 | key={cell.id} |
| 282 | style={{ |
| 283 | display: 'flex', |
| 284 | width: cell.column.getSize(), |
| 285 | }} |
| 286 | > |
| 287 | {flexRender(cell.column.columnDef.cell, cell.getContext())} |
| 288 | </td> |
| 289 | ) |
| 290 | })} |
| 291 | </tr> |
| 292 | ) |
| 293 | } |
| 294 | |
| 295 | // test out when rows don't re-render at all (future TanStack Virtual release can make this unnecessary) |
| 296 | const TableBodyRowMemo = React.memo( |
nothing calls this directly
no test coverage detected
searching dependent graphs…