mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
30 lines
627 B
TypeScript
30 lines
627 B
TypeScript
// eslint-disable-next-line
|
|
import React from "react";
|
|
|
|
import { List, RowComponentProps } from 'react-window';
|
|
|
|
import './VirtualList.css';
|
|
|
|
interface RowData {
|
|
items: any[];
|
|
}
|
|
|
|
const Row = ({ index, style, items }: RowComponentProps<RowData>) => (
|
|
<div style={style}>
|
|
{items[index]}
|
|
</div>
|
|
);
|
|
|
|
const VirtualList = ({ items, className = '', size = 30 }) => (
|
|
<div className="virtual-list">
|
|
<List<RowData>
|
|
className={`virtual-list__list ${className}`}
|
|
rowCount={items.length}
|
|
rowHeight={size}
|
|
rowComponent={Row}
|
|
rowProps={{ items }}
|
|
/>
|
|
</div>
|
|
);
|
|
|
|
export default VirtualList;
|