From 9ff003bec107a4934daf2a3cee73c40ec72e6999 Mon Sep 17 00:00:00 2001
From: Eug-VS <eug-vs@keemail.me>
Date: Mon, 3 Feb 2020 16:31:48 +0300
Subject: feat: migrate SmartList to Typescript

---
 src/lib/SmartList/SmartList.tsx | 44 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 src/lib/SmartList/SmartList.tsx

(limited to 'src/lib/SmartList/SmartList.tsx')

diff --git a/src/lib/SmartList/SmartList.tsx b/src/lib/SmartList/SmartList.tsx
new file mode 100644
index 0000000..c889719
--- /dev/null
+++ b/src/lib/SmartList/SmartList.tsx
@@ -0,0 +1,44 @@
+import React from 'react';
+import { FixedSizeList } from 'react-window';
+import AutoSizer from 'react-virtualized-auto-sizer';
+
+
+interface RenderPropTypes {
+  index: number;
+  style: any;
+}
+
+interface PropTypes {
+  itemSize: number;
+  itemCount: number;
+  renderItem: React.FC<RenderPropTypes>;
+}
+
+interface Size {
+  height: number;
+  width: number;
+}
+
+
+const SmartList: React.FC<PropTypes> = ({ itemSize, itemCount, renderItem }) => {
+
+  const ResizedList: React.FC<Size> = ({ width, height}) => (
+    <FixedSizeList
+      height={height}
+      width={width}
+      itemSize={itemSize}
+      itemCount={itemCount}
+    >
+      {renderItem}
+    </FixedSizeList>
+  );
+
+  return (
+    <div style={{ flex: '1 1 auto', overflow: 'hidden' }}>
+      <AutoSizer children={ResizedList} />
+    </div>
+  );
+};
+
+
+export default SmartList;
-- 
cgit v1.2.3

