Skip to content

Blazor local functions in ChildContent don't work correctly #10236

Open
@EngieDev

Description

@EngieDev

When I call local functions in @{} block inside a .razor component tag the content from the local function isn't getting rendered.

Home.razor

@page "/"

<h1>Issue showcase</h1>

<IssueComponent>
   <span>Hello 1</span>
</IssueComponent>

<IssueComponent>
   @{
       IssueLocalFunction();
   }
</IssueComponent>

@{
   void IssueLocalFunction()
   {
       <span>Hello 2</span>
   }
}

IssueComponent.razor

@ChildContent

@code {
    [Parameter]
    public RenderFragment? ChildContent { get; set; }
}

Output

image

It's getting showed when is prerendering but then it disappears.
Here is my repo with that issue:
https://github.com/EngieDev/BlazorComponentsIssue

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions