This code will help you to understand what to do if the component ref/instance is not working or the component ref is undefined.
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 } }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
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.
need an explanation for this answer? contact us directly to get an explanation for this answer