Match
A tradução desta página não existe ou está desatualizada, por isso é mostrada em inglês. Ler em inglês
Describe one branch of a Switch. Use it to associate a condition with a specific view.
Render the matching playback state
import { Match, Switch, Text, signal } from 'kuito';
export default function Status() {
const state = signal<'idle' | 'playing' | 'paused'>('idle');
return (
<Switch fallback={<Text>Nothing playing</Text>}>
<Match when={state.value === 'playing'}>
<Text>Playing</Text>
</Match>
<Match when={state.value === 'paused'}>
<Text>Paused</Text>
</Match>
</Switch>
);
}Behavior
Match must be directly inside Switch. Its when condition can track state. A callback child receives the truthy value, as with Show.
Continue
Read Control flow for a complete workflow. See the complete prop reference for types and documented defaults.
Referência
Assinaturas
<T>(props: MatchProps<T>): KuitoElementParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
T | — | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
props | MatchProps<T> | Sim | — |
Devolve
Props: MatchProps<T>
Props (incluindo props herdadas) 3
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
when | When<T> | Sim | — |
children | BranchChildren<T> | Não | — |
key | string | number | Não | — |
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.