ForProps
Props of For: the items, the row each renders, and what shows while there are none.
Utilização
Render a short checklist
Este tipo é usado por For
import { For, Scroll, Text, store } from 'kuito';
export function PackingList() {
const state = store({ items: [{ title: 'Passport' }, { title: 'Tickets' }] });
return (
<Scroll>
<For each={state.items} fallback={<Text>Add your first item</Text>}>
{(item, index) => <Text padding={12}>{`${index.value + 1}. ${item.title}`}</Text>}
</For>
</Scroll>
);
}Declaração do tipo
export interface ForProps<T> extends ElementAttributes {
/** The items: an array, a signal of one, or a store array. */
each: readonly T[] | ReadonlySignal<readonly T[]>;
/** Rendered while `each` is empty. */
fallback?: KuitoNode;
/** Renders an item's row once; `index` follows its position. */
children: (item: T, index: ReadonlySignal<number>) => KuitoNode;
}Membros 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.