aboutsummaryrefslogtreecommitdiff
path: root/src/components/SmartList/SmartList.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/SmartList/SmartList.js')
-rw-r--r--src/components/SmartList/SmartList.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/components/SmartList/SmartList.js b/src/components/SmartList/SmartList.js
new file mode 100644
index 0000000..975cbbd
--- /dev/null
+++ b/src/components/SmartList/SmartList.js
@@ -0,0 +1,39 @@
+import React from 'react';
+
+import { FixedSizeList } from 'react-window';
+import AutoSizer from 'react-virtualized-auto-sizer';
+
+import { makeStyles } from '@material-ui/core';
+
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ scrollbarColor: `${theme.palette.primary.dark} ${theme.palette.primary.light}`,
+ }
+}));
+
+
+const SmartList = ({ itemSize, itemCount, renderItem }) => {
+ const classes = useStyles();
+
+ return (
+ <div style={{ flex: '1 1 auto'}}>
+ <AutoSizer>
+ {({ width, height }) => (
+ <FixedSizeList
+ height={height}
+ width={width}
+ itemSize={itemSize}
+ itemCount={itemCount}
+ className={classes.root}
+ >
+ {renderItem}
+ </FixedSizeList>
+ )}
+ </AutoSizer>
+ </div>
+ );
+};
+
+
+export default SmartList;