Data
VirtualListNew in 0.8.0
A windowed list for huge or endlessly loading data. Rows can be a fixed height, individually known, or measured after render.
VirtualListPreview
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12
Item 13
Item 14
Only the rows near the viewport are mounted.
Usage
tsx
import { VirtualList } from "@vesture/react";
<VirtualList
items={rows}
height={360}
itemHeight={36}
getKey={(r) => r.id}
renderItem={(r) => <div>{r.text}</div>}
onEndReached={loadMore}
loading={isLoading}
/>Behavior
- Only the rows in (and just around) the viewport are mounted, so 100,000 items stay cheap.
- Omit itemHeight to measure rows with ResizeObserver, starting from estimateItemHeight — ideal for wrapping text.
- onEndReached fires once near the bottom and re-arms when items grows. It is suppressed while loading is true.
- Attach a ref for scrollToIndex(index, align) and scrollToTop().
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items / renderItem | T[] / (item, index) => ReactNode | — | Required. |
| height | number | — | Required. Viewport height in px. |
| itemHeight | number | (item, index) => number | — | Fixed or known heights. Omit to measure. |
| estimateItemHeight / gap / overscan | number | 44 / 0 / 4 | Layout tuning. |
| getKey | (item, index) => string | number | — | Stable keys (also used to cache measured heights). |
| onEndReached / endReachedThreshold | () => void / number | – / 200 | Infinite-scroll hook. |
| loading / loadingIndicator / emptyState | boolean / ReactNode | — | Status rows. |