Render the welcome content a second time:
@RenderWelcomeInfo @code { private RenderFragment RenderWelcomeInfo = @Welcome to your new app!
; } ``` To makeLast render DateTime: @dt
@code { private DateTime dt = DateTime.Now; private void HandleSelect() { dt = DateTime.Now; Logger.LogInformation("This event handler doesn't trigger a rerender."); } Task IHandleEvent.HandleEventAsync( EventCallbackWorkItem callback, object? arg) => callback.InvokeAsync(arg); } ``` In addition to preventing rerenders after event handlers fire in a component in a global fashion, it's possible to prevent rerenders after a single event handler by employing the following utility method. Add the following `EventUtil` class to a Blazor app. The static actions and functions at the top of the `EventUtil` class provide handlers that cover several combinations of arguments and return types that Blazor uses when handling events. `EventUtil.cs`: ```csharp using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Components; public static class EventUtil { public static Action AsNonRenderingEventHandler(Action callback) => new SyncReceiver(callback).Invoke; public static ActionLast render DateTime: @dt
@code { private DateTime dt = DateTime.Now; private void HandleClick1() { dt = DateTime.Now; Logger.LogInformation("This event handler triggers a rerender."); } private void HandleClick2() { dt = DateTime.Now; Logger.LogInformation("This event handler doesn't trigger a rerender."); } private void HandleClick3(MouseEventArgs args) { dt = DateTime.Now; Logger.LogInformation( "This event handler doesn't trigger a rerender. " + "Mouse coordinates: {ScreenX}:{ScreenY}", args.ScreenX, args.ScreenY); } } ``` In addition to implementing the} @code { private string heading = "Select a button to learn its position"; private void UpdateHeading(MouseEventArgs e, int buttonNumber) { heading = $"Selected #{buttonNumber} at {e.ClientX}:{e.ClientY}"; } } ``` :::moniker-end :::moniker range="< aspnetcore-8.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/event-handling/EventHandlerExample5.razor"::: :::moniker-end If a large number of buttons are rendered using the preceding approach, rendering speed is adversely impacted leading to a poor user experience. To render a large number of buttons with a callback for click events, the following example uses a collection of button objects that assign each button's `@onclick` delegate to an
} @code { private string heading = "Select a button to learn its position"; private List