For
A tradução desta página não existe ou está desatualizada, por isso é mostrada em inglês. Ler em inglês
Render a short collection while preserving item identity. Use it for tags, checklist rows and small menus.
Show a checklist with row numbers
import { For, Scroll, Text, store } from 'kuito';
const todo = store({ tasks: [{ title: 'Write', done: false }] });
export default function Tasks() {
return (
<Scroll>
<For each={todo.tasks} fallback={<Text>Nothing to do</Text>}>
{(task, index) => <Text>{index.value + 1 + '. ' + task.title}</Text>}
</For>
</Scroll>
);
}Behavior
each accepts an array, array signal or store array. index is a signal. Every item is mounted; choose List when the collection needs virtualization. fallback handles an empty collection.
Continue
Read Control flow for a complete workflow. See the complete prop reference for types and documented defaults.
Referência
Assinaturas
<T>(props: ForProps<T>): KuitoElementParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
T | — | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
props | ForProps<T> | Sim | — |
Devolve
Props: ForProps<T>
Props (incluindo props herdadas) 4
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
each | readonly T[] | ReadonlySignal<readonly T[]> | Sim | The items: an array, a signal of one, or a store array. |
fallback | KuitoNode | Não | Rendered while each is empty. |
children | (item: T, index: ReadonlySignal<number>) => KuitoNode | Sim | Renders an item's row once; index follows its position. |
key | string | number | Não | — |
children — assinaturas de método
Assinaturas
(item: T, index: ReadonlySignal<number>): KuitoNodeParâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
item | T | Sim | — |
index | ReadonlySignal<number> | Sim | — |
Devolve
Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.