Blazor Hybrid Lifecycle

684 Views Asked by At

Navigating away from a component page, then back to the component page causes the component to be re-instantiated and go through the full lifecycle events (OnInitialized,SetParameters, etc.). Anyone else seeing this? Anyone know why?

I've flaggged each lifecycle event and I can confirm this behavior is occurring.

1

There are 1 best solutions below

0
On BEST ANSWER

Blazor apps that prerender their content on the server call OnInitializedAsync twice:

  • Once when the component is initially rendered statically as part of the page.
  • A second time when the browser renders the component.

So, the ASP.NET Core Razor component lifecycle document gives the solutions Component initialization about the situation.