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
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- propsrequiredany
- The component props object (from defineProps).
- proprequiredstring
- The name of the prop key to watch and sync, e.g. "locale".
- providedrequiredRef<T>
- The injected fallback ref (e.g. from useLocale() at the ancestor level).
API
Return value
The value returned by this util.
- A reactive ref that mirrors the prop when set, or the provided value when the prop is null/undefined.
Usage
Examples
Ready-to-paste usage snippets.
Locale prop with provided fallback