Reader small image

You're reading from  .NET MAUI Cross-Platform Application Development - Second Edition

Product typeBook
Published inMar 2024
Reading LevelBeginner
PublisherPackt
ISBN-139781835080597
Edition2nd Edition
Languages
Right arrow
Author (1)
Roger Ye
Roger Ye
author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye

Right arrow

Understanding the Razor component lifecycle

A Razor component, like any other object, possesses a lifecycle. It consists of a series of synchronous and asynchronous lifecycle methods that developers can override to perform additional operations during component initialization and rendering.

Refer to Figure 10.7 for an overview of the Razor component lifecycle:

Figure 9.6: Razor component lifecycle

Figure 10.7: Razor component lifecycle

In Figure 10.7, it is evident that we have the ability to add hooks during both the initialization and rendering phases. The methods listed below can be overridden to capture initialization events:

  • SetParametersAsync
  • OnInitialized and OnInitializedAsync
  • OnParametersSet and OnParametersSetAsync

SetParametersAsync and OnInitializedAsync are invoked only in the first render. OnParametersSetAsync is called every time a parameter is changed.

The following methods can be overridden to customize rendering:

  • ShouldRender
  • OnAfterRender...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
.NET MAUI Cross-Platform Application Development - Second Edition
Published in: Mar 2024Publisher: PacktISBN-13: 9781835080597

Author (1)

author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye