Previous tip (Dynamic components) Next tip (Employ a little conditional CSS to shake up your UI) >>

Pass parameters when rendering components dynamically

DynamicComponent is really useful for rendering any component just by specifying its type.

But what about passing parameters?

For that you can provide a dictionary of parameters which are forwarded on to the component you’re attempting to render.

<DynamicComponent
Type="@componentType"
Parameters="@parameters" />
@code {
private Type componentType =
typeof(FetchData);
private IDictionary<string, object>
parameters = ...;
}