Blazor - Not All Code Paths Return A Value In Lambda Expression Of Type 'RenderFragment In Code Behind
Hello,
Cheers!
When I was transferring the C# Rendering Fragment snippet from the razor component to the code-behind class, I encountered this error which is "Not All Code Paths Return A Value In Lambda Expression Of Type 'RenderFragment<string> as presented on the code below.
@code{ private RenderFragment<string> intro = text => @<h3>@text</h3>; }
Afer reading the docs, this issue can be fixed in the code behind csharp class, by using the AddMarkUpContent() method builder parameter which will add HTML tags with content to the component as the delegate function of the RenderFragment object.
private RenderFragment<string> intro = (text) => builder => { builder.AddMarkupContent(0, $"<h3>{text}</h3>"); };
Cheers!
Comments
Post a Comment