Composables

usePrimitiveElement

Source
Resolve a template ref down to a stable ElementHandle regardless of asChild merging.
Advanced. Primitive-authoring utility from @vyui/core — most app code never calls this 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

PropertyTypeDescription
primitiveElementRef<T | undefined>Attach as the template ref on the primitive's root.
currentElementComputedRef<ElementHandle | undefined>The resolved element handle.