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
valueTLatest value (provided by the caller).
Returns
- T
First render: returns
valueas-is. Subsequent renders: returns the previously committed value and queues the next value as pending on the Transition lane. Render after a Transition flush: commits the pending value and returns the new value.
Type Parameters
TType of the value being deferred.
Remarks
Change detection matches UseStore<TStore, TSel>(Store<TStore>, Func<TStore, TSel>, IEqualityComparer<TSel>?): reference equality for objects, NaN-aware for float/double. 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
valueTLatest value (provided by the caller).
initialValueTValue returned on the initial render only.
Returns
- T
The initial render returns
initialValue; thereafter same as the single-arg overload.
Type Parameters
TType of the value being deferred.