Lifecycle
Override lifecycle methods to load data and react to parameter changes.
The methods
OnInitialized/OnInitializedAsync— runs once when the component is createdOnParametersSet/OnParametersSetAsync— runs when parameters changeOnAfterRender/OnAfterRenderAsync— runs after the DOM is updated (JS interop here)
Async loading
@code {
private Item[]? items;
protected override async Task OnInitializedAsync()
{
items = await Http.GetFromJsonAsync<Item[]>("/api/items");
}
}