Skip to content

Blazor - OnAfterRender sequence #12777

@harleydk

Description

@harleydk

Describe the bug

With a page which has a 'main' component in it, referencing sub-components, the main-components onAfterRender is called before the sub-components onAfterRender.
Deliberately not using the async versions.

onafterrender

Expected behavior

I expected the sub-components onAfterRender to run before the the main-component's onAfterRender. I wanted the sub-components to report back before the main-component, like Angular's ngAfterViewInit does it.

To Reproduce

Steps to reproduce the behavior:

  1. Using the latest .NET Core 3 preview with Latest VS 2019 Preview.
  2. Start a new Blazor client-side project
  3. Create a main-component which overrides the onAfterRender and writes a line to the console.
  4. Create a sub-component which overrides the onAfterRender and writes a line to the console.
  5. Create a page which has a main-component which holds a couple of sub-components inside of it.
  6. The main-component's onAfterRender will run before the sub-component's same.

ComponentPage.razor.txt
SubComponent.razor.txt
MainComponent.razor.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions