Ken Tola

Ken Tola

  • NA
  • 15
  • 727

swcreen is not defined in Blazor/Razor

Nov 23 2021 10:05 PM

Hi!

I have a Blazor Server App with the following in the code behind:

protected override async Task OnAfterRenderAsync(bool firstRender)
{
     if (firstRender)
     {
          await base.OnInitializedAsync();
          await SetDimensions();
          StateHasChanged();
     }
}
 

From my understanding, the OnAfterRenderAsync method is supposed to wait until the screen is rendered.  I even added in the OnInitializedAsync wait to make sure.

Unfortunately for me, however, I keep getting Unhandled exception rendering component: swcreen is not defined errors when my SetDimensions call runs.  This call is using JavaScript to move Div tags into the correct location on the screen.

Is there some other way to ensure that the screen is completed?

Thank you!