Why are Blazor lifecycle methods getting executed twice? what is the benefit of this feature?

290 views Asked by At

Why are Blazor lifecycle methods getting executed twice? what is the benefit of this feature?

1

There are 1 answers

0
enet On

They are executed twice because your application is pre-rendering. Note that while your application is pre-rendering JavaScript is not available. To opt for pre-rendering, set the render-mode attribute of the component Html tag helper to "ServerPrerendered", like the following:

<component type="typeof(App)" render-mode="ServerPrerendered" />

If you don't want pre-rendering, set the render-mode attribute to "Server"

That was the short answer. If you want a full-blown description as to why you need pre-rendering, what consideration you should take into account, etc., look up the subject in the docs...