The Blazor framework includes synchronous and asynchronous lifecycle methods. You can load the full page asynchronously using the below methods,
- OnInitializedAsync – It is invoked when the component is ready to start and has received its initial parameters from its parent in the render tree.
protected override async Task OnInitializedAsync()
{
await ...
}
- OnParametersSetAsync – It is invoked when the component is initialized and has received its first set of parameters from its parent component.
protected override async Task OnParametersSetAsync()
{
await ...
}
- OnAfterRenderAsync – It is invoked after a component has finished rendering. The firstRender is set to true at first time when the component instance is rendered.
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await ...
}
}
Share with