Table of Contents

Method UseDeferredValue

Namespace
Velvet
Assembly
Velvet.Docs.dll

UseDeferredValue<T>(T)

Defers commits of value changes through the Transition lane and returns the previous value during urgent re-renders. Use this to deprioritize heavy re-render inputs such as search queries.

public static T UseDeferredValue<T>(T value)

Parameters

value T

Latest value (provided by the caller).

Returns

T

First render: returns value as-is. Subsequent renders: returns the previously committed value and queues the next value as pending on the Transition lane. A re-render that is not draining that lane keeps returning the previously committed value and re-queues the lane. The render that drains the Transition lane: commits the pending value and returns the new value.

Type Parameters

T

Type of the value being deferred.

Remarks

Change detection matches the default comparer of UseStore<TStore, TSel>(Store<TStore>, Func<TStore, TSel>, IEqualityComparer<TSel>?). There is no comparer argument.

UseDeferredValue<T>(T, T)

Overload taking an initialValue. On the initial render the hook returns initialValue instead of value and immediately schedules a Transition-lane re-render that defers toward value. Subsequent renders behave exactly like UseDeferredValue<T>(T).

public static T UseDeferredValue<T>(T value, T initialValue)

Parameters

value T

Latest value (provided by the caller).

initialValue T

Value returned on the initial render only.

Returns

T

The initial render returns initialValue; thereafter same as the single-arg overload.

Type Parameters

T

Type of the value being deferred.