我使用tanstack 的 react-table v8创建了一个可重用的表组件。我现在尝试通过 tanstack 来实现react-virtual到这个可重用的表。我使用“@tanstack/react-virtual”:“^3.0.0-beta.54”和“@tanstack/react-table”:“^8.9.2”。我在网上找不到任何集成这两个库最新版本的示例。有人可以帮我解决这个问题吗?
import type { ReactElement } from "react";
import { useRef } from "react";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeaderCell,
TableRow,
} from "./style";
import {
flexRender,
getCoreRowModel,
useReactTable,
} from "@tanstack/react-table";
import type { ColumnDef } from "@tanstack/react-table";
import { useVirtualizer } from "@tanstack/react-virtual";
interface TableProps {
columns: Array<ColumnDef<any, string>>;
data: any;
}
function CustomTable(props: TableProps): ReactElement {
const { columns, data } = props;
const parentRef = useRef<HTMLTableElement>(null);
const …Run Code Online (Sandbox Code Playgroud)