I’ve found that the jamstacks (blazor wasm with tailwind) template causes the page lifecycle hooks to all fire twice on a reload.
This can be recreated by adding an OnAfterRender override to the index page…
@inject ILogger<Index> Logger
...
<GettingStarted />
@code {
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
Logger.LogWarning("index: first render");
}
base.OnAfterRender(firstRender);
}
}
This lifecycle hook is only supposed to fire once where firstRender = true, but it in the jamstacks templates it fires twice:
This can result in unnecessary api calls being made to the server.
Once loaded, on navigation the hook only fires once, its just on the initial load.
The default dotnet blazor wasm application does not exhibit the same behaviour.
Has anyone else found the same or come up with a solution?