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
handleRefRef<THandle>Parent-supplied Ref<T> that receives the handle. May be null.
factoryFunc<THandle>Factory invoked to build the handle on every render. Must not be null.
Type Parameters
THandleHandle 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
handleRefRef<THandle>The ref the parent passed via
componentRef:.factoryFunc<THandle>Produces the handle; re-invoked when
depschange.depsobject[]Dependency array gating recomputation.
Type Parameters
THandleThe imperative handle type exposed to the parent.