Null Program state breaks `MvuComponentBuilder`
Closed this issue · 2 comments
Uses of let! model = Mvu.State
within MvuComponentBuilder
views fail at runtime when the Program
state is represented as null.
I think this happens because ComponentContext.TryGetValue
returns ValueNone
when the underlying state is null, assuming it's not a valid representation for the state.
This is a problem specially because values such as ()
and None
are also represented as null, so components with state type unit
or option
are inherently broken. Even worse, both the Avalonia and MAUI implementations wrap the top-level view with an MvuComponentBuilder
, then provide a Program.stateless
helper which immediately triggers this issue.
This repro repository triggers the exception at the binder for the root component of the Avalonia implementation linked above.
Hi @amongonz!
Thanks for the report.
This is indeed an issue. I also saw it happen when using a unit model ()
which is represented as null
at runtime.
Components are still very much bleeding edge and I'm actively working on it. I will fix that issue in the next preview version.