@arcmantle/lit-jsx / runtime/for-component
runtime/for-component
Functions
For()
For<
T,U>(props):unknown
Defined in: runtime/for-component.ts:24
Renders a list of items with optional keys and separators.
Type Parameters
T
T
The type of items in the array
U
U extends unknown
The JSX element type returned by the render function
Parameters
props
children
(item, index) => U
Render function that receives each item and its index
each
readonly T[]
Array of items to render
key?
(item, index) => any
Optional key function for efficient updates (uses lit-html's repeat directive)
separator?
unknown
Optional JSX element to insert between items
Returns
unknown
An iterator from either the map or repeat directive, depending on whether a key function is provided.
Example
tsx
<For each={users} key={(user) => user.id}>
{(user, index) => <div key={user.id}>{user.name}</div>}
</For>