Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@page "/counter"
@inject IJSRuntime js
<div @ref="container">
<p>Current count: @currentCount</p>
<button id="counterClick" class="btn btn-primary counterClickC" @onclick="IncrementCount">Click me</button>
@code {
private ElementReference container;
protected async override Task OnAfterRenderAsync(bool firstRender)
if (firstRender)
await js.InvokeVoidAsync("initializeCounterComponent", container);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment