The component instance filed is populated along with the component after rendering completion. You must access the component instance in the OnAfterRenderAsync or OnAfterRender methods of the Blazor lifecycle.
@page "/"
<Counter IncrementValue="10" @ref="counter"></Counter>
@code {
private Counter counter;
protected override void OnAfterRender()
{
base.OnAfterRender();
counter.increase(); //access counter instance here
}
}
Share with