Skip to content

Latest commit

 

History

History
184 lines (96 loc) · 5.2 KB

WindowVirtualizerProps.md

File metadata and controls

184 lines (96 loc) · 5.2 KB

API


Interface: WindowVirtualizerProps

Props of WindowVirtualizer.

Properties

children

children: ReactNode | (index) => ReactElement<any, string | JSXElementConstructor<any>>

Elements rendered by this component.

You can also pass a function and set WindowVirtualizerProps.count to create elements lazily.

Defined in

src/react/WindowVirtualizer.tsx:63


count?

optional count: number

If you set a function to WindowVirtualizerProps.children, you have to set total number of items to this prop.

Defined in

src/react/WindowVirtualizer.tsx:67


overscan?

optional overscan: number

Number of items to render above/below the visible bounds of the list. Lower value will give better performance but you can increase to avoid showing blank items in fast scrolling.

Default Value

4

Defined in

src/react/WindowVirtualizer.tsx:72


itemSize?

optional itemSize: number

Item size hint for unmeasured items. It will help to reduce scroll jump when items are measured if used properly.

  • If not set, initial item sizes will be automatically estimated from measured sizes. This is recommended for most cases.
  • If set, you can opt out estimation and use the value as initial item size.

Defined in

src/react/WindowVirtualizer.tsx:79


shift?

optional shift: boolean

While true is set, scroll position will be maintained from the end not usual start when items are added to/removed from start. It's recommended to set false if you add to/remove from mid/end of the list because it can cause unexpected behavior. This prop is useful for reverse infinite scrolling.

Defined in

src/react/WindowVirtualizer.tsx:83


horizontal?

optional horizontal: boolean

If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.

Defined in

src/react/WindowVirtualizer.tsx:87


cache?

optional cache: CacheSnapshot

You can restore cache by passing a CacheSnapshot on mount. This is useful when you want to restore scroll position after navigation. The snapshot can be obtained from WindowVirtualizerHandle.cache.

The length of items should be the same as when you take the snapshot, otherwise restoration may not work as expected.

Defined in

src/react/WindowVirtualizer.tsx:93


ssrCount?

optional ssrCount: number

A prop for SSR. If set, the specified amount of items will be mounted in the initial rendering regardless of the container size until hydrated.

Defined in

src/react/WindowVirtualizer.tsx:97


as?

optional as: CustomContainerComponent | keyof IntrinsicElements

Component or element type for container element.

Default Value

"div"

Defined in

src/react/WindowVirtualizer.tsx:102


item?

optional item: CustomItemComponent | keyof IntrinsicElements

Component or element type for item element. This component will get CustomItemComponentProps as props.

Default Value

"div"

Defined in

src/react/WindowVirtualizer.tsx:107


onScroll()?

optional onScroll: () => void

Callback invoked whenever scroll offset changes.

Returns

void

Defined in

src/react/WindowVirtualizer.tsx:111


onScrollEnd()?

optional onScrollEnd: () => void

Callback invoked when scrolling stops.

Returns

void

Defined in

src/react/WindowVirtualizer.tsx:115