Suppress UI refreshing in Blazor using ShouldRender

@page "/control-render"

    <input type="checkbox" @bind="shouldRender" />
    Should Render?

<p>Current count: @currentCount</p>

    <button @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;
    private bool shouldRender = true;

    protected override bool ShouldRender()
        return shouldRender;

    private void IncrementCount()

ShouldRender is called each time a component is rendered. Override ShouldRender to manage UI refreshing. If the implementation returns true, the UI is refreshed.

Even if ShouldRender is overridden, the component is always initially rendered.