type-alias / @typed/ui/Dom/Refs

ComposedRef

Ref callback produced by combining two compatible element refs.

Learn this UI primitive →

Package version
1.0.0-beta.7
Category
Ref composition
Since
1.0.0

Import

import type { ComposedRef } from "@typed/ui/Dom/Refs";

Signatures

export type ComposedRef<First, Second> = ((element: RefTarget<First> & RefTarget<Second>) => Effect.Effect<void, RefError<First> | RefError<Second>, RefServices<First> | RefServices<Second>>) & HydrationProtocol<First> & HydrationProtocol<Second>;

Why

User and component refs can observe the exact same DOM element without one overwriting the other, while their error/service channels remain visible.

Ownership and lifetime

The callback sequences both refs inside the element’s rendering Scope. At most one input may carry HydrationRef ownership; that protocol is retained on the composed callback.

Source