I have 3 components. When I want is to call the New()
method of component C from component B.
That works with following code (I get the Console.Writeline). But the UI is not updating. I have tried to set StateHaseChanged()
in the New()
method, but that gave me following errors. Many Thanks!
Error
WASM: System.InvalidOperationException: The render handle is not yet assigned.
ComponentA (SideBar Item)
<NavLink href="@href">
<div @onclick="OnClick.InvokeAsync">@Text</div>
</NavLink>
@code {
[Parameter] public string Text { get; set; }
[Parameter] public EventCallback OnClick { get; set; }
}
ComponentB (SideBar)
<ComponentA Text="Something" Onclick="@(() => componentC.New())" />
@code {
ComponentC componentC = new ComponentC();
}
ComponentC (Page)
@code {
public void New()
{
//Dostuff..
Console.WriteLine("Testing");
//StateHasChanged();
}
}
ComponentB
usesComponentC
internally (in the @code block). Is this correct? – Artak