diff options
author | eug-vs <eug-vs@keemail.me> | 2020-10-10 13:39:08 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-10-10 13:39:08 +0300 |
commit | bfa9f7b9158faa3a453eaabf5be3c96b6c8a18b1 (patch) | |
tree | 1f8b2b987b24ecacb9b1fe62ce57d1f0ac6f6230 /src/demo/SmartList | |
parent | c33c6a521325adafb250124d2814423b3a4187b5 (diff) | |
download | react-benzin-bfa9f7b9158faa3a453eaabf5be3c96b6c8a18b1.tar.gz |
refactor: remove demo components from lib
Diffstat (limited to 'src/demo/SmartList')
-rw-r--r-- | src/demo/SmartList/SmartList.tsx | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/demo/SmartList/SmartList.tsx b/src/demo/SmartList/SmartList.tsx new file mode 100644 index 0000000..c86c127 --- /dev/null +++ b/src/demo/SmartList/SmartList.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { FixedSizeList } from 'react-window'; +import AutoSizer from 'react-virtualized-auto-sizer'; + + +interface RenderPropTypes { + index: number; + style: React.CSSProperties; +} + +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; |