Live Chat Icon For mobile
Live Chat Icon

What is the purpose of component initialization methods in Blazor?

Platform: Blazor| Category : General, Lifecycle

Blazor provides both synchronous and asynchronous initialization lifecycle methods to perform additional operations on components during initialization and rendering. Initialization methods are:

  • OnInitialized:  Override this method in components for synchronous operations. 
  • OnInitializedAsync:  Override this method in components for asynchronous operations.

    OnInitialized and OnInitializedAsync are executed when the component is initialized after having received its initial parameters from its parent component in the render tree. 

    Use OnInitializedAsync when the component performs an asynchronous operation and the changes should refresh the component when the operation is completed.

    Refer to this link for more details. 

    Share with

    Related FAQs

    Couldn't find the FAQs you're looking for?

    Please submit your question and answer.