Description
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe the problem.
Blazor could use the function of detecting the first loading of a component / subpage by the server.
If we use OnInitializedAsync
it will work like this:
- Execute code on first entry (server side)
- Will execute the same code again after loading the page or moving dynamically (e.g. to a subpage)
If we have a subpage where the code takes longer to load (e.g. we wait for the API), a problem arises. The first load is delayed by this component.
In case we don't want to be indexed by bots, there should be a function like don't do it on server side. We can do a Skeleton and wait for the task to be done.
It is possible to do this by PersistentComponentState
, but it is not convenient and there are problems with many components (you can call it only once)
I propose to do something like this:
protected override async Task OnInitializedAsync()
{
if(AppState.ServerRendering == false){
// Code that does not require rendering during server rendering
}
}
or
protected override async Task OnInitializedDynamicAsync(){
// Code that does not require rendering during server rendering
}
I also know about the existence of OnAfterRenderAsync
but it doesn't render the code on the server side.
Describe the solution you'd like
Let me know what you think, I think letting the developer decide whether the code is to be rendered server-side or not is a good solution. This will prevent the problem of delaying the entire page by, for example, one component.
Additional context
No response