fix: skip rendering list when data is empty

This commit is contained in:
Nikola Ubavic 2022-01-14 14:00:36 +01:00
parent cfb360ab4e
commit 044090a8f1

View file

@ -185,22 +185,24 @@ const DataTable = ({
<TBody className={classes.body}>
{loading && <H4>Loading...</H4>}
{!loading && R.isEmpty(data) && <EmptyTable message={emptyText} />}
<AutoSizer disableWidth>
{({ height }) => (
<List
// this has to be in a style because of how the component works
style={{ overflow: 'inherit', outline: 'none' }}
{...props}
height={loading ? 0 : height}
width={width}
rowCount={data.length}
rowHeight={cache.rowHeight}
rowRenderer={rowRenderer}
overscanRowCount={5}
deferredMeasurementCache={cache}
/>
)}
</AutoSizer>
{!R.isEmpty(data) && (
<AutoSizer disableWidth>
{({ height }) => (
<List
// this has to be in a style because of how the component works
style={{ overflow: 'inherit', outline: 'none' }}
{...props}
height={loading ? 0 : height}
width={width}
rowCount={data.length}
rowHeight={cache.rowHeight}
rowRenderer={rowRenderer}
overscanRowCount={5}
deferredMeasurementCache={cache}
/>
)}
</AutoSizer>
)}
</TBody>
</Table>
</Box>