Skip to content

Allow custom component instantiation #7962

@CatoLeanTruetschel

Description

@CatoLeanTruetschel

Change the access modifier of ComponentFactory to public to allow instatiation of components.

An even better solution is to add an interface IComponentFactory that is implemented by ComponentFactory and that is registered in the ServiceCollection.

My current use case for this:
I implemented a system to split a blazor/razor-components project into multiple modules that are loaded lazily. The modules define view-extensions that can be rendered whereever needed. The view-extension rendering engines does not know about the concrete type of the component at compile time but needs to instantiate a component (of a type that is known at runtime), configure it with some values and finally render it. Currently I need to copy the source of ComponentFactory to my project to allow this.

If you like, I can implement this and open a PR for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions