Inherited
A value a component provides to its descendants, read with inherit()
wherever they are below it. fallback is what they read when no
component above them provides one.
Utilização
Share a value with descendants
Este tipo é usado por inherit
import { Text, VStack, inherit, inherited, provide, signal } from 'kuito';
const Currency = inherited('EUR');
function Price() {
const currency = inherit(Currency);
return <Text>{`12 ${currency.value}`}</Text>;
}
export function Checkout() {
const currency = signal('USD');
provide(Currency, currency);
return (
<VStack>
<Price />
</VStack>
);
}Declaração do tipo
export interface Inherited<T> {
readonly fallback: T;
}Membros 1
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
fallbacksó de leitura | T | Sim | — |
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.