Utilização

Reveal a profile after its resource settles

Este tipo é usado por Catch

tsx
import { Catch, Loading, Spinner, Text, resource } from 'kuito';

function Profile() {
  const profile = resource(async ({ signal }) => {
    const response = await fetch('https://example.com/api/profile', { signal });
    if (!response.ok) throw new Error(`HTTP ${response.status}`);
    return (await response.json()) as { name: string };
  });
  return <Text>{profile.data.value?.name ?? ''}</Text>;
}

export function Account() {
  return (
    <Catch fallback={<Text>Profile unavailable</Text>}>
      <Loading fallback={<Spinner />}>
        <Profile />
      </Loading>
    </Catch>
  );
}

Declaração do tipo

ts
export interface CatchProps extends ElementAttributes {
  /** Shown in place of children that threw: an element, or one made from the error. */
  fallback: KuitoNode | ((error: unknown, retry: () => void) => KuitoNode);
  children?: KuitoNode;
}

Membros 3

NomeTipoObrigatórioDescrição
fallbackKuitoNode | ((error: unknown, retry: () => void) => KuitoNode)SimShown in place of children that threw: an element, or one made from the error.
childrenKuitoNodeNão—
keystring | numberNã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.