LoadingProps
Props of Loading: the children, and what it shows while their resources load.
Utilisation
Reveal a profile after its resource settles
Ce type est utilisé par Loading
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>
);
}Déclaration du type
export interface LoadingProps extends ElementAttributes {
/** Shown in place of the children while their resources load. */
fallback?: KuitoNode;
children?: KuitoNode;
}Membres 3
Généré depuis les déclarations TypeScript publiques : signatures, props et valeurs par défaut viennent de la source vérifiée, les descriptions de sa JSDoc. Aucune valeur par défaut n'est inventée.