1.13.96 • Published 2 years ago

@myntra/uikit-component-virtual-list v1.13.96

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

import VirtualList from './src/virtual-list'

VirtualList

const [items] = useState(
  Array(5000)
    .fill(0)
    .map(() => ~~(50 * Math.random()))
);

<VirtualList
  itemCount={5000}
  viewportSize={250}
  style={{ height: '250px', minWidth: '200px' }}
>
  {({ index, style }) => (
    <div
      style={{
        padding: `${10 + items[index]}px 24px`,
        backgroundColor: `hsl(${(index * 15) % 360}deg, 75%, 80%)`,
        ...style,
        left: 0,
        right: 0,
      }}
    >
      Hello {index + 1} ({items[index]})
    </div>
  )}
</VirtualList>