Skip to content

StatePanelWidget

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

A widget that provides identity-anchored scope for its child subtree. The state object's reference identity determines which node is reused across reconciliation frames, enabling state preservation across list reorders.

csharp
public sealed record StatePanelWidget : Hex1bWidget, IEquatable<Hex1bWidget>, IEquatable<StatePanelWidget>

Inheritance

ObjectHex1bWidgetStatePanelWidget

Implements

Constructors

StatePanelWidget(object, Func<StatePanelContext, Hex1bWidget>)

A widget that provides identity-anchored scope for its child subtree. The state object's reference identity determines which node is reused across reconciliation frames, enabling state preservation across list reorders.

Parameters:

csharp
public StatePanelWidget(object StateKey, Func<StatePanelContext, Hex1bWidget> Builder)

Properties

Builder

Returns: Func<StatePanelContext, Hex1bWidget>

csharp
public Func<StatePanelContext, Hex1bWidget> Builder { get; init; }

StateKey

Returns: Object

csharp
public object StateKey { get; init; }

Remarks

The builder is deferred to reconciliation time (like ), so the has access to the resolved node's current state.

When nested under another StatePanelNode, identity resolution uses the ancestor's registry dictionary keyed by reference equality. Without an ancestor, falls back to positional matching with a state key reference check.

Important: The StateKey is compared by reference identity (). Use a stable reference-type object (e.g., a view model instance). Value types and freshly-boxed objects will not match across frames.

Examples

csharp
ctx.StatePanel(myViewModel, sp =>
    sp.Text($"Count: {myViewModel.Count}")
);

Released under the MIT License.