provide
Called while a component sets up: its descendants inherit value for
key. A signal (a computed too) is what they read: a write reaches the
bindings that read it, and nothing re-renders.
Utilização
Share a value with descendants
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>
);
}Assinaturas
<T>(key: Inherited<T>, value: T | ReadonlySignal<T>): voidParâmetros de tipo
| Nome | Restrição | Predefinição |
|---|---|---|
T | — | — |
Parâmetros
| Nome | Tipo | Obrigatório | Descrição |
|---|---|---|---|
key | Inherited<T> | Sim | — |
value | T | ReadonlySignal<T> | Sim | — |
Devolve
void
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.