Method Memoized
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Memoized(Func<VNode>, params object?[]?)
Memoization node. Skips rebuilding the child subtree while the dependency array is unchanged.
When key is omitted, the order of MemoNodes within the same component must remain stable,
since the node is identified by its position in the element it is written into. If the order can
change dynamically, use
MemoizedWithKey(string?, Func<VNode>, params object?[]?) instead. This is distinct from
Memo<TProps>(Func<TProps, VNode>, TProps, Func<TProps, TProps, bool>, string?), which
memoizes a function-style component by props equality.
public static MemoNode Memoized(Func<VNode> factory, params object?[]? deps)
Parameters
factoryFunc<VNode>Factory invoked to produce the cached VNode when
depschange.depsobject[]Dependency values. When equal to the previous render, the cached VNode is reused; Dependencies states the branch each element type takes. Pass an empty array to declare no dependencies and keep the cached subtree while the memo keeps its position; null declares no dependency array, which no newly built node's comparison can satisfy.
Returns
Memoized(Func<VNode>)
Declares no dependency array, for a factory whose inputs are not expressible as one: a newly built node never reuses the cached subtree, so a call site inside a render body rebuilds every render.
public static MemoNode Memoized(Func<VNode> factory)
Parameters
factoryFunc<VNode>Factory invoked on every reconcile to produce the subtree.
Returns
Remarks
The single-argument overload exists so that omitting deps is unambiguous — see UseCallback<T>(T) for the hazard it avoids. To keep the cached subtree while the memo keeps its position instead, pass an empty array.