Hooks
Hooks are only available through the current function component's
ComponentContext context. CSX function component methods must declare
ComponentContext context as their first parameter; plain C# root components
receive it from window.Render(context => { ... }).
Hooks are stored by render order, similar to React. Do not change hook order by calling hooks conditionally.
var count = context.UseState(0);
var button = new Button($"Count {count.Value}");
button.OnClick += (_, _) => count.Update(static value => value + 1);
return button;
Set and Update request a render when the value changes. Use app.Flush() in
offline tests, or await app.PendingRender.
UseReducer stores reducer state and exposes Dispatch(action). UseMemo
recomputes only when dependencies change. UseEffect runs after the committed
DOM frame and disposes the previous cleanup before running the next effect.