mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Update react-virtual to 3rd version
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
1 parent
5cce219387
commit
4b887e6c7c
4 files changed
+42
-25
No files matched your search
@@ -1,5 +1,5 @@
|
||||
.tableTheme {
|
||||
height: calc(100% - 59px);
|
||||
height: 708px;
|
||||
overflow: auto;
|
||||
|
||||
table {
|
||||
@@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
tr {
|
||||
margin: calc(var(--margin) * 1.6) var(--margin);
|
||||
// margin: calc(var(--margin) * 1.6) var(--margin);
|
||||
}
|
||||
|
||||
th {
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import { flexRender, Row } from '@tanstack/react-table'
|
||||
import { flexRender, Row } from "@tanstack/react-table"
|
||||
import type { Table } from "@tanstack/react-table";
|
||||
import { TableHeader } from "./table-header";
|
||||
import { useVirtual } from 'react-virtual'
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
|
||||
interface TableProps<T> {
|
||||
table: Table<T>;
|
||||
@@ -18,22 +18,27 @@
|
||||
const tableContainerRef = React.useRef<HTMLDivElement>(null)
|
||||
|
||||
const { rows } = table.getRowModel()
|
||||
const rowVirtualizer = useVirtual({
|
||||
parentRef: tableContainerRef,
|
||||
size: rows.length,
|
||||
overscan: 10,
|
||||
const rowVirtualizer = useVirtualizer({
|
||||
getScrollElement: () => tableContainerRef.current,
|
||||
estimateSize: () => 55,
|
||||
overscan: 5,
|
||||
count: rows.length
|
||||
})
|
||||
const { virtualItems: virtualRows } = rowVirtualizer;
|
||||
|
||||
console.log(`${rowVirtualizer.getTotalSize()}px`)
|
||||
|
||||
return (
|
||||
<div className={className} ref={tableContainerRef}>
|
||||
<table>
|
||||
<table style={{ height: 1590 }}>
|
||||
<TableHeader table={table}/>
|
||||
<tbody>
|
||||
{virtualRows.map(virtualRow => {
|
||||
{rowVirtualizer.getVirtualItems().map(virtualRow => {
|
||||
const row = rows[virtualRow.index] as Row<Data>
|
||||
return (
|
||||
<tr key={row.id}>
|
||||
<tr
|
||||
key={row.id}
|
||||
// style={{ height: 30 }}
|
||||
>
|
||||
{row.getVisibleCells().map(cell => {
|
||||
return (
|
||||
<td key={cell.id} style={{ width: cell.column.getSize() }}>
|
||||
|
||||
Reference in new issue
Block a user