I have created a MAUI Blazor App and a Blazor WEB App (.NET 8) and a common Razor Class Library using out of the box projects.
My problem is the how to put the Counter.Razor page into the Razor Class Library. The Counter.Razor file needs interactivity, so in the Web App-version there is the line:
@rendermode InteractiveAuto
This line is not recognized by the MAUI Blazor Hybrid app, so this will give an compiler error.
If the line is deleted, the MAUI Blazor Hybrid app will work as expected, but the Web App will have no interactivity.
What is the correct/best way to share Razor components with the need for interactivity in a Razor Class Library?
As per the Ms Docs, that @Brian linked in the comments.
It's recommended to not declare
@rendermode
in the components that are in a Razor Class Library, instead they should be applied the@rendermode
when the component is instantiated. e.g.