blob: 6cd774b8c2cf68002e313c07bd95a7c427afbd30 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import React from 'react';
import { FixedSizeList } from "react-window";
import { makeStyles } from "@material-ui/core";
const useStyles = makeStyles(theme => ({
root: {
scrollbarColor: `${theme.palette.primary.dark} ${theme.palette.primary.light}`,
}
}));
const SmartList = ({ height, width, cellHeight, itemCount, renderItem }) => {
const classes = useStyles();
if (!height) {
const windowHeight = window.innerHeight;
const headerHeight = document.getElementsByClassName("MuiAppBar-root")[0].clientHeight;
height = windowHeight - headerHeight
}
return (
<FixedSizeList
height={height}
width={width}
itemSize={cellHeight}
itemCount={itemCount}
className={classes.root}
>
{renderItem}
</FixedSizeList>
);
};
export default SmartList;
|