Discovering the component life cycle
Blazor components go through a set of methods from initialization to rendering and finally being disposed of. These methods have synchronous and asynchronous versions that we can leverage to perform certain tasks.
The following list shows the methods that the components go through; not all of them are being called. Being called depends on whether the component is being rendered for the first time:
SetParameterAsync
: This sets the value of the parameters from the component parent and the route parameters. (More about route parameters will be covered in Chapter 4, Navigation and Routing.)
The default implementation of this method sets the values of the parameters and the cascading parameters available. SetParameterAsync
is called only for the first render of the component. Overriding its implementation allows you to control the process of setting the values of the parameters and write some logic based on that, as shown in the BookCard...