<div id="Counter">
    @(await Html.RenderComponentAsync<Counter>(new { IncrementAmount = 10 }))
</div>

why would i use this when i can just use

<counter IncrementAmount="10"/>

"When the page or view is rendered, components are prerendered at the same time."

https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0

thanks

1 Answers

2
Chris Sainty On Best Solutions

The code sample you’ve quoted is used when you want to include a Blazor component into a MVC view or a Razor page. If you’re just writing a standard Blazor app then you wouldn’t need this syntax.

When using this syntax the component is going to be prerendered on the server and will become interactive once a SignalR connection has been established with the client browser.