@rendermode InteractiveWebAssembly @inject IJSRuntime JS @inject GPW.CORE.Services.UserStateService UState @inject ILogger Log @code { private readonly Guid _instanceId = Guid.NewGuid(); protected override async Task OnAfterRenderAsync(bool firstRender) { if (!firstRender) return; Log.LogInformation("UserBootstrapClient OnAfterRenderAsync instance {Id}", _instanceId); try { var json = await JS.InvokeAsync("localStorage.getItem", "currUser"); if (!string.IsNullOrEmpty(json)) { var user = System.Text.Json.JsonSerializer.Deserialize(json); if (user != null) { Log.LogInformation("UserBootstrapClient setting user in instance {Id}", _instanceId); UState.SetUser(user); } } } catch (Exception ex) { Log.LogError(ex, "UserBootstrapClient error instance {Id}", _instanceId); } } }