Composables
usePrimitiveElement
Resolve a template ref down to a stable ElementHandle regardless of asChild merging.
Advanced. This is a primitive-authoring utility from
@vyui/core that most app code never calls directly.Overview
import { usePrimitiveElement } from '@vyui/core'
const { primitiveElement, currentElement } = usePrimitiveElement()
Resolves a template ref, which may be a component instance or a raw element since Lynx's <view> / <text> aren't DOM elements, down to a stable ElementHandle, the thing every @vyui/core primitive uses internally to get "the actual rendered element" regardless of whether asChild merged it into something else.
Returns
| Property | Type | Description |
|---|---|---|
primitiveElement | Ref<T | undefined> | Attach as the template ref on the primitive's root. |
currentElement | ComputedRef<ElementHandle | undefined> | The resolved element handle. |