fn
useForwardExpose
v0.0.14testeddemoForwards a child component's exposed API and DOM element (`$el`) through the parent component. Useful for wrapper / headless components that need to transparently proxy the inner component's ref to the consumer. Merges the parent's own props and any prior `expose()` bindings onto `instance.exposed`, then updates them when `forwardRef` is called with a child element or component instance.
Examples
ts
const { forwardRef, currentElement } = useForwardExpose();
// Template: <ChildComponent :ref="forwardRef" />ts
const { forwardRef, currentRef } = useForwardExpose<InstanceType<typeof MyInput>>();
// Template: <MyInput :ref="forwardRef" />
// currentRef.value exposes MyInput's public APIDemo
Loading demo…
Signature
ts
export function useForwardExpose<T extends ComponentPublicInstance>(): UseForwardExposeReturn<T>{ ... }Type Parameters
Textends ComponentPublicInstanceReturns
UseForwardExposeReturn<T>An object with `forwardRef`, `currentRef`, and `currentElement`