Table of Contents

Property Memoize

Namespace
Velvet
Assembly
Velvet.Docs.dll

Memoize

Opt-in props-bail: skip a parent-driven re-render when this component's props are shallow-equal to the previous render — the props bag compared member by member, each member decided by the per-type rule Dependencies states. A props value that is not a props bag — a value type, a string, a collection — is compared whole under that same rule instead of through a member set, so two distinct collections of equal content are a change. Any other value type is decided by its own Equals, which reads what it holds, and then — on this path alone — the float and double fields it carries, directly or inside a value type it holds, are compared by raw bit pattern on top of that, so +0 and -0 in one of those are a change as two float members are. That last reading is not part of the cited rule and the dependency comparison does not take it, so the same pair reaching a hook as a dependency is unchanged. ComponentPropsComparerTests is what fails if either half of the props answer stops holding, and ObjectIsTests if the dependency answer starts taking it. Default is false.

Only a component with Memoize = true, or one mounted with V.Memo and its comparer, skips a parent-driven render on props judged equal. Whether a component's body runs on a render that reaches it is Compiler's to say.

Unrelated to MemoizeMethodAttribute: that attribute drives per-method wrapping by the Source Generator, while this property is the per-component props-bail flag at the reconcile boundary. The shared Memoize root is all the two have in common.

public bool Memoize { get; init; }

Property Value

bool