What's new in Version 2

Describes the list of changes present in Version 2 of MauiReactor

MauiReactor 2 is the new version of MauiReactor targeting .NET 8. It contains some good improvements, many of which are under the hood. If you're coming from version 1 there is good news: your code is mostly working as it is. There are just a couple of breaking changes you need to be aware of.

Source code: https://github.com/adospace/reactorui-maui License: MIT (i.e. you can use it for your closed-source commercial projects) Let's start with what is new.

A new simplified way to write components

In Version 1, components are generally written with code like this:

class CounterPageState
{
    public int Counter { get; set; }
}

class CounterPage : Component<CounterPageState>
{
    public override VisualNode Render()
    {
        return new ContentPage("Counter Sample")
        {
            new VStack(spacing: 10)
            {
                new Label($"Counter: {State.Counter}")
                    .VCenter()
                    .HCenter(),

                new Button("Click To Increment", () =>
                    SetState(s => s.Counter++))
            }
            .VCenter()
            .HCenter()
        };
    }
}

In Version 2, you can use the new format that is less verbose and more easy to read

The new code style is optional. You can use the other way to write your component or leave the code you may have already written as it will work in Version 2+.

[Prop], [Param], and [Inject] attributes

Version 2 provides a few convenient source generators that should remove some boilerplate code in your components.

The PropAttribute lets specify a component prop without writing the method.

Before:

After (version 2+):

Please note that the component class must be partial to use the new feature.

The ParamAttribute allows you to specify a parameter that is inherited from the parent component without the boilerplate code Create/GetParameter.

Before

After (version 2+):

Finally, you may also find useful the InjectAttribute that lets you remove some repetitive code to inject services from the DI container

Before:

After (version 2+):

All the new attributes are optional and require the component class to be partial.

Breaking Changed: Simplified creation of inline components

Version 2 provides a more straightforward method for creating Inline Components that is easier to read requiring less boiler code.

Before:

After (version 2+):

Breaking changed: Reactor.Maui.ScaffoldGenerator package dismissed

When you authored components wrapping native controls coming from external libraries you were required to install an additional packaged Reactor.Maui.ScaffoldGenerator.

This is no longer required as the source generators library is now directly linked by the main package Reactor.Maui.

Last updated

Was this helpful?