Table of Contents

Method VirtualList

Namespace
Velvet
Assembly
Velvet.Docs.dll

VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)

Creates a vertical virtualized list.

public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, float itemHeight, Func<T, VNode> renderer, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)

Parameters

items IReadOnlyList<T>

Source collection.

keySelector Func<T, string>

Selector that derives a per-item key.

itemHeight float

Item height in pixels.

renderer Func<T, VNode>

Builds each rendered item.

overscan int

Extra items rendered beyond each edge.

key string

The list's key among its siblings.

className string

Utility classes for the list.

name string

The list element's name.

listRef Ref<VirtualListHandle>

Receives the mounted list's handle.

events FiberEventBinding[]

Event bindings applied to the list's ScrollView (Documentation~/react-migration.md owns the rule). The array is read and never written.

Returns

VirtualListNode

Type Parameters

T

Element type of the source collection.

VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)

Virtualized list component for rendering large item collections. Renders a ScrollView of items of one height and only places the visible range in the DOM (a virtualized list).

public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, float itemHeight, Func<T, VNode> renderer, bool horizontal, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)

Parameters

items IReadOnlyList<T>

Source collection. Must not be null.

keySelector Func<T, string>

Selector that derives a stable per-item key. Must not be null. The key is compared only with the other keys of this list, so it is not held to Key's rule on what a key may contain. A null key is no key, the answer List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>) gives the same selector: the row renders, and a range change reuses it by its item index. Items sharing a key all render and are told apart by their item index, each keeping the row rendered at its own index while it stays in the range; two of them rendered in one range log a warning naming the key.

itemHeight float

Height (pixels) of every item, used for layout and visible-range calculation.

renderer Func<T, VNode>

Function that produces a VNode for each visible item. Must not be null. A key it sets on the node it returns plays no part in which row a range change reuses — keySelector's key does — and the node is left as the renderer returned it, so one node returned for several items does not merge their rows. A throw of its own is not contained — it reaches the caller, and the range update it ends leaves the list showing no rows.

horizontal bool

Lay the items out in a row and scroll the list sideways, FlashList's horizontal; itemHeight is then each item's width.

overscan int

Extra items rendered above/below the visible window to smooth scroll-in.

key string

Key used to disambiguate siblings at the same position.

className string

CSS-like utility class string. Multiple classes separated by spaces.

name string

Element name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.

listRef Ref<VirtualListHandle>

Ref set to the list's VirtualListHandle while it is mounted.

events FiberEventBinding[]

Event bindings applied to the list's ScrollView (Documentation~/react-migration.md owns the rule). The array is read and never written.

Returns

VirtualListNode

The created VirtualListNode.

Type Parameters

T

Element type of the source collection.

Exceptions

ArgumentException

Thrown when key contains a NUL character.

VirtualList<T>(IReadOnlyList<T>, Func<T, string>, Func<int, float>, Func<T, VNode>, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)

Creates a vertical virtualized list.

public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<int, float> itemHeight, Func<T, VNode> renderer, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)

Parameters

items IReadOnlyList<T>

Source collection.

keySelector Func<T, string>

Selector that derives a per-item key.

itemHeight Func<int, float>

Item height in pixels at an index.

renderer Func<T, VNode>

Builds each rendered item.

overscan int

Extra items rendered beyond each edge.

key string

The list's key among its siblings.

className string

Utility classes for the list.

name string

The list element's name.

listRef Ref<VirtualListHandle>

Receives the mounted list's handle.

events FiberEventBinding[]

Event bindings applied to the list's ScrollView (Documentation~/react-migration.md owns the rule). The array is read and never written.

Returns

VirtualListNode

Type Parameters

T

Element type of the source collection.

VirtualList<T>(IReadOnlyList<T>, Func<T, string>, Func<int, float>, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)

Virtualized list whose items each take the height itemHeight gives for their index — react-window's rowHeight function. Every other parameter is VirtualList<T>(IReadOnlyList<T>, Func<T, string>, float, Func<T, VNode>, bool, int, string?, string?, string?, Ref<VirtualListHandle>?, FiberEventBinding[]?)'s.

public static VirtualListNode VirtualList<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<int, float> itemHeight, Func<T, VNode> renderer, bool horizontal, int overscan = 3, string? key = null, string? className = null, string? name = null, Ref<VirtualListHandle>? listRef = null, FiberEventBinding[]? events = null)

Parameters

items IReadOnlyList<T>

Source collection. Must not be null.

keySelector Func<T, string>

Selector that derives a stable per-item key. Must not be null.

itemHeight Func<int, float>

Height (pixels) of the item at an index. Must not be null. It is asked for every item each time the list renders.

renderer Func<T, VNode>

Function that produces a VNode for each visible item. Must not be null.

horizontal bool

Lay the items out in a row and scroll the list sideways, FlashList's horizontal; itemHeight is then each item's width.

overscan int

Extra items rendered above/below the visible window to smooth scroll-in.

key string

Key used to disambiguate siblings at the same position.

className string

CSS-like utility class string. Multiple classes separated by spaces.

name string

Element name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.

listRef Ref<VirtualListHandle>

Ref set to the list's VirtualListHandle while it is mounted.

events FiberEventBinding[]

Event bindings applied to the list's ScrollView (Documentation~/react-migration.md owns the rule). The array is read and never written.

Returns

VirtualListNode

The created VirtualListNode.

Type Parameters

T

Element type of the source collection.

Exceptions

ArgumentException

Thrown when key contains a NUL character.