Table of Contents

Method List

Namespace
Velvet
Assembly
Velvet.Docs.dll

List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>)

Builds a keyed VNode list from a collection by mapping each item to a VNode and attaching a stable per-item key. If renderer returns null for an item, the slot is included in the array but renders nothing: the reconciler's inline expansion drops it. A node a list has placed before — returned for an earlier item, or held from an earlier render — keeps the key it was placed under; where the selected key differs, its slot takes a copy of the node carrying that key.

public static VNode?[] List<T>(IReadOnlyList<T> items, Func<T, string> keySelector, Func<T, VNode> renderer)

Parameters

items IReadOnlyList<T>

Source collection. When null or empty, returns an empty VNode array.

keySelector Func<T, string>

Selector that derives a stable per-item key. A null key leaves the item unkeyed, matched by its index, and logs a warning the first time a component's list does so, as React warns about a list child with no key.

renderer Func<T, VNode>

Function that produces a VNode for each item.

Returns

VNode[]

Array of rendered VNodes (each carrying the selected key).

Type Parameters

T

Element type of the source collection.

Exceptions

ArgumentException

Thrown when keySelector returns a key containing a NUL character, after renderer has run for that item and every item before it.

List<T>(IReadOnlyList<T>, Func<T, int, string>, Func<T, int, VNode>)

Builds a keyed VNode list from an indexed collection, mapping each item together with its index to a VNode. A node a list has placed before is placed as List<T>(IReadOnlyList<T>, Func<T, string>, Func<T, VNode>) places one.

public static VNode?[] List<T>(IReadOnlyList<T> items, Func<T, int, string> keySelector, Func<T, int, VNode> renderer)

Parameters

items IReadOnlyList<T>

Source collection. When null or empty, returns an empty VNode array.

keySelector Func<T, int, string>

Selector that derives a stable per-item key from the item and its index. A null key is treated as the overload above treats one.

renderer Func<T, int, VNode>

Function that produces a VNode from the item and its index.

Returns

VNode[]

Array of rendered VNodes (each carrying the selected key).

Type Parameters

T

Element type of the source collection.

Exceptions

ArgumentException

Thrown when keySelector returns a key containing a NUL character, after renderer has run for that item and every item before it.