Skip to content

Render parent component from child component #33381

@dotnetspark

Description

@dotnetspark

Background and Motivation

@javiercn say I have a component (Foo) currently displayed on a page. Then I decide all instances of Foo should be rendered inside a container (<div>). Do it manually sounds great when Foo is just being used few times, but not ideal if usability is high. Then, I create a Parent component to render the container and I make Foo to inherit Parent. The idea is any time Foo is rendered it should also render the parent it inherits from.
The big question is, Is this possible today? The way BuildRenderTree works is forward only (if I'm not mistaken), thus it renders parent then child. I haven't seen child then parent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedapi-suggestionEarly API idea and discussion, it is NOT ready for implementationarea-blazorIncludes: Blazor, Razor Componentsquestion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions