Unable to override OnAfterRenderAsync in client side blazor
Quoting ASP.NET Core and Blazor updates in .NET Core 3.0 Preview 9's Upgrade an existing project:
- Replace
OnAfterRender()
andOnAfterRenderAsync()
implementations withOnAfterRender(bool firstRender)
orOnAfterRenderAsync(bool firstRender)
.
Since NET Core 3.0 Preview 9 OnAfterRender
receives a boolean parameter to let method know if this is the first render. Very useful to avoid controlling it by yourself:
Sample about how to replace old code to new one, red old code, green new one.
try this
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
}
}
Note that both OnAfterRenderAsync and OnAfterRender has a boolen parameter you may call firstRender
protected override async Task OnInitializedAsync()
{
}
Indeed, that should work with no issues as this is the correct method signature of OnInitializedAsync