Table of Contents

Method UseImperativeHandle

Namespace
Velvet
Assembly
Velvet.Docs.dll

UseImperativeHandle<THandle>(Ref<THandle>, Func<THandle>)

Builds a public handle (via factory) and stores it into the Ref<T> the parent passed via componentRef:. This no-deps overload re-invokes the factory every render (equivalent to passing null as deps); it exists so omitting deps is unambiguous — the params object[] overload would otherwise observe an empty array (not null) and incorrectly freeze the handle to the first render.

public static void UseImperativeHandle<THandle>(Ref<THandle> handleRef, Func<THandle> factory) where THandle : class

Parameters

handleRef Ref<THandle>

Parent-supplied Ref<T> that receives the handle. May be null.

factory Func<THandle>

Factory invoked to build the handle on every render. Must not be null.

Type Parameters

THandle

Handle type exposed to the parent.

UseImperativeHandle<THandle>(Ref<THandle>, Func<THandle>, params object?[]?)

Builds a handle via factory and stores it into the parent-supplied Ref<T>, rebuilding only when deps change (compared with Object.is semantics).

public static void UseImperativeHandle<THandle>(Ref<THandle> handleRef, Func<THandle> factory, params object?[]? deps) where THandle : class

Parameters

handleRef Ref<THandle>

The ref the parent passed via componentRef:.

factory Func<THandle>

Produces the handle; re-invoked when deps change.

deps object[]

Dependency array gating recomputation.

Type Parameters

THandle

The imperative handle type exposed to the parent.