From 142ef97911abaec96c5bc0779b322374437a56b5 Mon Sep 17 00:00:00 2001 From: Eug-VS Date: Wed, 8 Jan 2020 22:04:49 +0300 Subject: Wrap SmartList into AutoSizer This component now takes all available space, so if you want to use it, you have to put it into a container which already has non-zero width and height. This commit temporarily breaks Scoreboard page. --- src/components/SmartList/SmartList.js | 37 ++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'src/components') diff --git a/src/components/SmartList/SmartList.js b/src/components/SmartList/SmartList.js index 6cd774b..975cbbd 100644 --- a/src/components/SmartList/SmartList.js +++ b/src/components/SmartList/SmartList.js @@ -1,8 +1,9 @@ import React from 'react'; -import { FixedSizeList } from "react-window"; +import { FixedSizeList } from 'react-window'; +import AutoSizer from 'react-virtualized-auto-sizer'; -import { makeStyles } from "@material-ui/core"; +import { makeStyles } from '@material-ui/core'; const useStyles = makeStyles(theme => ({ @@ -12,25 +13,25 @@ const useStyles = makeStyles(theme => ({ })); -const SmartList = ({ height, width, cellHeight, itemCount, renderItem }) => { +const SmartList = ({ itemSize, itemCount, renderItem }) => { const classes = useStyles(); - if (!height) { - const windowHeight = window.innerHeight; - const headerHeight = document.getElementsByClassName("MuiAppBar-root")[0].clientHeight; - height = windowHeight - headerHeight - } - return ( - - {renderItem} - +
+ + {({ width, height }) => ( + + {renderItem} + + )} + +
); }; -- cgit v1.2.3