Fix white screen: add error boundaries and improve error handling in AnalyticsProvider and useWebVitals

This commit is contained in:
2026-01-10 17:07:00 +01:00
parent 2a260abe0a
commit 832b468ea7
4 changed files with 91 additions and 43 deletions

View File

@@ -4,6 +4,7 @@ import React, { useEffect, useState } from "react";
import { usePathname } from "next/navigation";
import dynamic from "next/dynamic";
import { ToastProvider } from "@/components/Toast";
import ErrorBoundary from "@/components/ErrorBoundary";
import { AnalyticsProvider } from "@/components/AnalyticsProvider";
// Dynamic import with SSR disabled to avoid framer-motion issues
@@ -46,13 +47,20 @@ export default function ClientProviders({
};
}, [pathname]);
// Wrap in multiple error boundaries to isolate failures
return (
<AnalyticsProvider>
<ToastProvider>
{mounted && <BackgroundBlobs />}
<div className="relative z-10">{children}</div>
{mounted && !is404Page && <ChatWidget />}
</ToastProvider>
</AnalyticsProvider>
<ErrorBoundary>
<ErrorBoundary>
<AnalyticsProvider>
<ErrorBoundary>
<ToastProvider>
{mounted && <BackgroundBlobs />}
<div className="relative z-10">{children}</div>
{mounted && !is404Page && <ChatWidget />}
</ToastProvider>
</ErrorBoundary>
</AnalyticsProvider>
</ErrorBoundary>
</ErrorBoundary>
);
}