You can also use @rendermode Razor directive and applying a render mode to a component definition.
This works on my end:
@rendermode InteractiveAuto
or to be more specific:
@rendermode InteractiveServer
By applying this directive, it could also solve the given exception.