Components (JSX)

Repeat

Creates a list of elements from a count.

Receives a map function as its child that takes the index and returns a JSX element; if the count is zero, an optional fallback is rendered instead.


Import

import { Repeat } from "solid-js";

Type signature

function Repeat<T extends SolidElement>(props: {
count: number;
from?: number | undefined;
fallback?: SolidElement;
children: ((index: number) => T) | T;
});

Examples

<Repeat count={items.length} fallback={<div>No items</div>}>
{(index) => <div data-index={index}>{items[index]}</div>}
</Repeat>
Last updated: 7/4/26, 6:21 PMEdit this pageReport an issue with this page