mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
* feat: baseline virtualization for table * merge branch canary * fix: table layout * fix: calc header height w layouteffect to offset padding * Merge branch 'canary' into feat/eng-1633-virtualization-for-table * chore: remove unused files and comments * chore: add missing package * feat: add shouldVirtualize conditional to render virtualized-table * feat: update docs for table * feat: use wrapper to support theme styles * chore: add changeset * chore(changeset): update package name * chore(deps): pnpm-lock.yaml * fix(table): outdated package name * chore(changeset): add issue number * fix(deps): keep the version consistent with other components * fix(table): incorrect displayName * refactor(table): use VirtualizedTemplate * chore(deps): bump `@tanstack/react-virtua` * chore(deps): typecheck issue * fix(table): do not use any type * chore: remove auto virtualization --------- Co-authored-by: աӄա <wingkwong.code@gmail.com> Co-authored-by: Junior Garcia <jrgarciadev@gmail.com>
38 lines
983 B
JavaScript
38 lines
983 B
JavaScript
import {Table, TableBody, TableCell, TableColumn, TableHeader, TableRow} from "@nextui-org/react";
|
|
|
|
function generateRows(count) {
|
|
return Array.from({length: count}, (_, index) => ({
|
|
key: index.toString(),
|
|
name: `Item ${index + 1}`,
|
|
value: `Value ${index + 1}`,
|
|
}));
|
|
}
|
|
|
|
export default function App() {
|
|
const rows = generateRows(500);
|
|
const columns = [
|
|
{key: "name", label: "Name"},
|
|
{key: "value", label: "Value"},
|
|
];
|
|
|
|
return (
|
|
<Table
|
|
isVirtualized
|
|
aria-label="Example of virtualized table with a large dataset"
|
|
maxTableHeight={300}
|
|
rowHeight={40}
|
|
>
|
|
<TableHeader columns={columns}>
|
|
{(column) => <TableColumn key={column.key}>{column.label}</TableColumn>}
|
|
</TableHeader>
|
|
<TableBody items={rows}>
|
|
{(item) => (
|
|
<TableRow key={item.key}>
|
|
{(columnKey) => <TableCell>{item[columnKey]}</TableCell>}
|
|
</TableRow>
|
|
)}
|
|
</TableBody>
|
|
</Table>
|
|
);
|
|
}
|