Reputation: 11
Why are Blazor lifecycle methods getting executed twice? what is the benefit of this feature?
Upvotes: 0
Views: 296
Reputation: 45724
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...
Upvotes: 2