useDefaults
Commons
stable
Component-side hook for the OrigamDefaultsProvider system. Returns a Proxy over the component's own props that resolves each value through a four-level chain: explicitly passed prop → component-specific defaults from the closest provider → global defaults from the closest provider → withDefaults() value.
API
Signature
Signature TypeScript complète extraite du fichier du composable.
The wasPropPassed check reads vm.vnode.props on every resolution (not once at setup) to handle dynamic v-bind patterns where the parent's forwarded props may be empty on the first render.
Interfaces consommées
IDefault
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- propsrequisT
- The component's reactive props object (as returned by defineProps).
- namestringgetCurrentInstanceName()
- Component name used to look up component-specific defaults in the provider. Defaults to the current instance's kebab-cased name via getCurrentInstanceName().
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- (proxied props)
- A Proxy wrapping the original props. Every property read goes through the four-level resolution chain. Object.keys(), spread, and filterProps still see the original prop names. Non-prop accesses (Vue internals, symbols) are forwarded to the original props directly.
Usage
Exemples
Extraits de code prêts à coller.
Opt in to defaults resolution in a component
Provide defaults for a subtree