Fix can't use useLoaderData in an error boundary

This commit is contained in:
Kalle
2022-12-08 21:50:10 +02:00
parent 56b28c9c77
commit 1c21e333ae

View File

@@ -132,7 +132,7 @@ function Document({
useChangeLanguage(locale);
usePreloadTranslation();
useTrackPageView();
useTrackPageView(data);
return (
<html lang={locale} dir={i18n.dir()} className={htmlThemeClass}>
@@ -186,9 +186,8 @@ function usePreloadTranslation() {
}, []);
}
function useTrackPageView() {
function useTrackPageView(data?: RootLoaderData) {
const location = useLocation();
const data = useLoaderData<typeof loader>();
React.useEffect(() => {
if (data?.gtmId) {