import * as React from 'react'; import Table from '@mui/material/Table'; import TableBody from '@mui/material/TableBody'; import TableCell from '@mui/material/TableCell'; import TableContainer from '@mui/material/TableContainer'; import TableHead from '@mui/material/TableHead'; import TableRow from '@mui/material/TableRow'; import Paper from '@mui/material/Paper'; import { TableVirtuoso, TableComponents } from 'react-virtuoso'; import Chance from 'chance'; interface Data { id: number; firstName: string; lastName: string; age: number; phone: string; state: string; } interface ColumnData { dataKey: keyof Data; label: string; numeric?: boolean; width?: number; } const chance = new Chance(42); function createData(id: number): Data { return { id, firstName: chance.first(), lastName: chance.last(), age: chance.age(), phone: chance.phone(), state: chance.state({ full: true }), }; } const columns: ColumnData[] = [ { width: 100, label: 'First Name', dataKey: 'firstName', }, { width: 100, label: 'Last Name', dataKey: 'lastName', }, { width: 50, label: 'Age', dataKey: 'age', numeric: true, }, { width: 110, label: 'State', dataKey: 'state', }, { width: 130, label: 'Phone Number', dataKey: 'phone', }, ]; const rows: Data[] = Array.from({ length: 200 }, (_, index) => createData(index)); const VirtuosoTableComponents: TableComponents = { Scroller: React.forwardRef((props, ref) => ( )), Table: (props) => ( ), TableHead: React.forwardRef((props, ref) => ( )), TableRow, TableBody: React.forwardRef((props, ref) => ( )), }; function fixedHeaderContent() { return ( {columns.map((column) => ( {column.label} ))} ); } function rowContent(_index: number, row: Data) { return ( {columns.map((column) => ( {row[column.dataKey]} ))} ); } export default function ReactVirtualizedTable() { return ( ); }