Table of Contents

Method UseCallback

Namespace
Velvet
Assembly
Velvet.Docs.dll

UseCallback<T>(T)

Returns the latest callback every render without memoization. With no deps argument the callback behaves as identity — a fresh closure each render. Use this overload only when you intentionally want the unmemoized form (e.g. handler that already captures no render-scoped state). For memoized stable references prefer the UseCallback<T>(T, params object?[]) overload with an explicit deps array.

public static T UseCallback<T>(T callback) where T : Delegate

Parameters

callback T

Returns

T

Type Parameters

T

Remarks

The single-argument overload exists so that omitting deps is unambiguous: the params object?[] deps overload would otherwise observe an empty array (not null) and incorrectly freeze the callback to the first-render closure.

UseCallback<T>(T, params object?[])

Returns the same delegate reference as long as the dependency array is unchanged.

public static T UseCallback<T>(T callback, params object?[] deps) where T : Delegate

Parameters

callback T

Callback to memoize. Captured on first render and on dependency changes.

deps object[]

Dependency values. When deeply equal to the previous render, the cached callback is reused.

Returns

T

The cached callback reference (stable across renders while deps are equal).

Type Parameters

T

Delegate type to memoize.