title: Blazor client side refresh component
body: <p>I'm trying to figure out how to refresh the client-side component after button click.</p>
  <p>Repo Link with example: <strong><a href="https://github.com/ovie91/RefreshComponent" rel="nofollow noreferrer">https://github.com/ovie91/RefreshComponent</a></strong></p>
  <p>Site /test or from nav menu test</p>
  <p>So I have OnInitializedAsync method that is retrieving data from API</p>
  <pre><code>protected override async Task OnInitializedAsync()
  {
       result = await (some API Call);
  }
  </code></pre>
  <p>Then I have a method connected to the button</p>
  <pre><code>private async void ButtonClick()
  {
       await (some API Call);
       result = null;
       this.StateHasChanged(); &lt;--- Doesnt work :&lt;
  }
  </code></pre>
  <p>I have tried to use <strong>this.StateHasChanged();</strong> but there is no reaction.
  As a workaround, I can force you to navigate again to the same website but this refresh &quot;Whole&quot; website but not a component.</p>
  <p>Any ideas on how to deal with it?</p>
  <p>whole code (stripped to minimum):</p>
  <pre><code>@page &quot;/test&quot;
  @inject HttpClient Http
  
  @if (result == null)
      {
       &lt;p&gt;Loading...&lt;p&gt;
      }
      else
      {
      @result
       &lt;button @onclick=&quot;(() =&gt; ButtonClick())&quot;&gt;Click&lt;/button&gt;
      }
  
  @code {
  
    private APIObject result;
  
    protected override async Task OnInitializedAsync()
    {
       result = await (some API Call);
    }
    private async void ButtonClick()
    {
       await (some API Call);
       result = null;
       this.StateHasChanged(); &lt;--- Doesnt work :&lt;
    }
  }
  </code></pre>
  <p><strong>Update</strong>
  I want to refresh component so OnInitializedAsync would be triggered again and that would mean I don't have to run the same code again after button click. Hope you understand what I mean.</p>