Posts

Showing posts from June, 2022

Dynamic Component in Blazor

Image
This blog is going to explain what a Dynamic Component is and how to use it. It is a built-in component used to render components by type. The Dynamic Component has two arguments which are type and parameter. Type is a component type and parameter is the parameter to be sent to the component. Let's see how to implement Dynamic Components in Blazor. Below is a basic example of how to implement Dynamic Components. The "typeof(Counter)" is assigned to the Type property. It will render the Counter component in the index page. index.razor @page   "/"   < h3 > Dynamic Component Demo </ h3 > < h4 > Index Page </ h4 >   < DynamicComponent   Type = "typeof(Counter)"  /> The following image is the output of the code snippets above. You can see here the Counter Component is rendered by Dynamic Component. Pass Parameter Let us see how to send the parameter to the component. The Dynamic Component sends