Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Custom ErrorBoundary implementation re-renders the whole component tree

$
0
0

I have this custom ErrorBoundary implementation in my Blazor WebAssembly app.

@using App.Services@inherits ErrorBoundaryBase@inject ToasterService _toasterService@inject ILogger<CustomErrorBoundary> _logger@ChildContent@code{    protected override Task OnErrorAsync(Exception exception)    {        var message = "Error in application. Please contact administrator.";        _logger.LogError(exception, message);        _toasterService.DisplayError(message);        return Task.CompletedTask;    }}

And it's used in my App.razor file like this.

<CustomErrorBoundary><ToastContainer/><TelerikRootComponent><CascadingAuthenticationState><Router AppAssembly="@typeof(App).Assembly"><Found Context="routeData"><div class="body-wrapper"><AuthorizeRouteView RouteData="@routeData"                                            DefaultLayout="@typeof(MainLayout)"><NotAuthorized><RedirectToLogin/></NotAuthorized></AuthorizeRouteView><FocusOnNavigate RouteData="@routeData"                                         Selector="h1"/></div><Footer/></Found><NotFound><RedirectToHome/></NotFound></Router></CascadingAuthenticationState></TelerikRootComponent></CustomErrorBoundary>

My goal with this implementation is to display a generic toaster message for the user and it works. However, the whole component tree inside the custom ErrorBoundary is re-rendered. Is there a way to avoid this behaviour?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>