useProvided

Commons
stable

Create a two-way-bound ref that falls back to an injected provided value when the component prop is null. The ref stays in sync with the provided value unless the consumer explicitly overrides it via the prop.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

props
requis
any
The component props object (from defineProps).
prop
requis
string
The name of the prop key to watch and sync, e.g. "locale".
provided
requis
Ref<T>
The injected fallback ref (e.g. from useLocale() at the ancestor level).

API

Valeur de retour

La valeur retournée par cet util.

A reactive ref that mirrors the prop when set, or the provided value when the prop is null/undefined.

Usage

Exemples

Extraits de code prêts à coller.

Locale prop with provided fallback

typescript