AuthorizeView with SessionStorageService error JavaScript interop calls cannot be issued at this time
hi,
currently i am getting this error: JavaScript interop calls cannot be issued at this time when get token from SessionStorageService (AuthorizeView ) in blazor sever net8, how can i fix?
when i leave it this : <component type="typeof(App)" render-mode="ServerPrerendered" />
in host.cshml then it ok, but UI nothing.
Can you help me?
@inherits LayoutComponentBase
@inject IJSRuntime JsRuntime
@using BlazorApp.Pages.Authentication
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject IHttpContextAccessor HttpContextAccessor
@inject Blazored.SessionStorage.ISessionStorageService sessionStorage
<AuthorizeView>
<Authorized>
<div class="bg-[#f9fbfd] dark:bg-dark text-black">
<div class="bg-[url('assets/images/bg-main.png')] bg-black min-h-[220px] sm:min-h-[250px] bg-bottom fixed hidden w-full -z-50 detached-img"></div>
<div x-cloak class="fixed inset-0 bg-black/60 dark:bg-dark/90 z-[999] lg:hidden" :class="{'hidden' : !$store.app.sidebar}" @click="ToggleSidebar">
</div>
<div class="flex mx-auto main-container">
<Sidebar></Sidebar>
<div class="flex-1 main-content">
<Topbar></Topbar>
<div class="h-[calc(100vh-60px)] relative overflow-y-auto overflow-x-hidden p-4 space-y-4 detached-content">
@Body
<Footer></Footer>
</div>
</div>
</div>
</div>
</Authorized>
<NotAuthorized>
<RedirectToLogin />
</NotAuthorized>
</AuthorizeView>
<button type="button" class="fixed z-50 px-4 text-white border-gray-200 shadow-lg h-11 ltr:right-0 rtl:left-0 bg-purple ltr:rounded-l-md rtl:rounded-r-md top-1/3" @onclick="ToggleDirection">
@if (direction == "ltr")
{
<span>LTR</span>
}
else
{
<span>RTL</span>
}
</button>