Method UseMemo
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
UseMemo<T>(Func<T>)
Recomputes factory on every render (no memoization). With no deps argument the
value is never cached — prefer the UseMemo<T>(Func<T>, params object?[]?) overload with an
explicit deps array to reuse the value while the dependencies are unchanged.
public static T UseMemo<T>(Func<T> factory)
Parameters
factoryFunc<T>Factory invoked every render to produce the value.
Returns
- T
The freshly computed value.
Type Parameters
TType of the value to compute.
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 value to the first-render computation.
UseMemo<T>(Func<T>, params object?[]?)
Returns the same computed value as long as the dependency array is unchanged; recomputes
factory only when a dependency changes.
public static T UseMemo<T>(Func<T> factory, params object?[]? deps)
Parameters
factoryFunc<T>Factory invoked to produce the value on the first render and whenever the deps change.
depsobject[]Dependency values. When deeply equal to the previous render, the cached value is reused.
Returns
- T
The cached value (stable across renders while
depsare equal).
Type Parameters
TType of the value to memoize.