'Cannot use build function inside BuildRenderTree Blazor WASM
I want to build Blazor components dynamically but i am having a weird error on WASM while the same code in Server-Side works.
I am sorry but i do not know how to explain the error or bug in details but basically if i build the Component on the overriden RenderBuildTree it works correctly, but if i call another BuildFunction inside the RenderBuildTree i get a System.InvalidOperationException: The render handle is not yet assigned.
error.
To reproduce the error, try typing something into the TextField and clicking out of it to trigger the ValueChanged.
Minimal reproducible code: https://try.mudblazor.com/snippet/ckQmYGOeIEycwaoV
Solution 1:[1]
You call it on the wrong instance.
The core problem is TestBaseComponent TestBaseComponent = new();
public class TestComponentBuilder : ComponentBase
{
// private static readonly TestBaseComponent TestBaseComponent = new();
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
// TestBaseComponent.Build(builder);
builder.OpenComponent(1, typeof(TestBaseComponent));
builder.CloseComponent();
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Henk Holterman |
