For
Die Übersetzung dieser Seite fehlt oder ist veraltet, daher wird sie auf Englisch angezeigt. Auf Englisch lesen
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.
Referenz
Signaturen
<T>(props: ForProps<T>): KuitoElementTypparameter
| Name | Einschränkung | Standard |
|---|---|---|
T | — | — |
Parameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
props | ForProps<T> | Ja | — |
Rückgabe
Props: ForProps<T>
Props (einschließlich geerbter Props) 4
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
each | readonly T[] | ReadonlySignal<readonly T[]> | Ja | The items: an array, a signal of one, or a store array. |
fallback | KuitoNode | Nein | Rendered while each is empty. |
children | (item: T, index: ReadonlySignal<number>) => KuitoNode | Ja | Renders an item's row once; index follows its position. |
key | string | number | Nein | — |
children — Methodensignaturen
Signaturen
(item: T, index: ReadonlySignal<number>): KuitoNodeParameter
| Name | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
item | T | Ja | — |
index | ReadonlySignal<number> | Ja | — |
Rückgabe
Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.