/** * Copyright (c) OpenLens Authors. All rights reserved. * Licensed under MIT License. See LICENSE in root directory for more information. */ import React from "react"; import { flexRender, Row } from '@tanstack/react-table' import type { Table } from "@tanstack/react-table"; import { TableHeader } from "./table-header"; import { useVirtual } from 'react-virtual' interface TableProps { table: Table; className?: string; } export function VirtualTable({ className, table }: TableProps) { const tableContainerRef = React.useRef(null) const { rows } = table.getRowModel() const rowVirtualizer = useVirtual({ parentRef: tableContainerRef, size: rows.length, overscan: 10, }) const { virtualItems: virtualRows } = rowVirtualizer; return (
{virtualRows.map(virtualRow => { const row = rows[virtualRow.index] as Row return ( {row.getVisibleCells().map(cell => { return ( ) })} ) })}
{flexRender( cell.column.columnDef.cell, cell.getContext() )}
) }