mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
upgrade packages + improve typing
This commit is contained in:
parent
fd55f4fb7f
commit
19f5eefdd2
138 changed files with 4504 additions and 11015 deletions
|
|
@ -1,34 +1,29 @@
|
|||
// eslint-disable-next-line
|
||||
import React from "react";
|
||||
|
||||
import { FixedSizeList as List } from 'react-window';
|
||||
import AutoSizer from 'react-virtualized-auto-sizer';
|
||||
import { List, RowComponentProps } from 'react-window';
|
||||
|
||||
import './VirtualList.css';
|
||||
|
||||
const VirtualList = ({ items, itemKey, className = {}, size = 30 }) => (
|
||||
<div className="virtual-list">
|
||||
<AutoSizer>
|
||||
{({ height, width }) => (
|
||||
<List
|
||||
className={`virtual-list__list ${className}`}
|
||||
height={height}
|
||||
width={width}
|
||||
itemData={items}
|
||||
itemCount={items.length}
|
||||
itemSize={size}
|
||||
itemKey={itemKey}
|
||||
>
|
||||
{Row}
|
||||
</List>
|
||||
)}
|
||||
</AutoSizer>
|
||||
interface RowData {
|
||||
items: any[];
|
||||
}
|
||||
|
||||
const Row = ({ index, style, items }: RowComponentProps<RowData>) => (
|
||||
<div style={style}>
|
||||
{items[index]}
|
||||
</div>
|
||||
);
|
||||
|
||||
const Row = ({ data, index, style }) => (
|
||||
<div style={style}>
|
||||
{data[index]}
|
||||
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>
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue