From 1c21e333ae0fbacecf320d0283a31478b22daa0e Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 8 Dec 2022 21:50:10 +0200 Subject: [PATCH] Fix can't use `useLoaderData` in an error boundary --- app/root.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/root.tsx b/app/root.tsx index f1b0dfd6c..b26c1352f 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -132,7 +132,7 @@ function Document({ useChangeLanguage(locale); usePreloadTranslation(); - useTrackPageView(); + useTrackPageView(data); return ( @@ -186,9 +186,8 @@ function usePreloadTranslation() { }, []); } -function useTrackPageView() { +function useTrackPageView(data?: RootLoaderData) { const location = useLocation(); - const data = useLoaderData(); React.useEffect(() => { if (data?.gtmId) {