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.
Utilisation
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>
);
}Signatures
<T>(key: Inherited<T>, value: T | ReadonlySignal<T>): voidParamètres de type
| Nom | Contrainte | Par défaut |
|---|---|---|
T | — | — |
Paramètres
| Nom | Type | Requis | Description |
|---|---|---|---|
key | Inherited<T> | Oui | — |
value | T | ReadonlySignal<T> | Oui | — |
Retourne
void
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.