Skip to content

Commit 04d4f4c

Browse files
authored
Merge pull request #308 from HerrBertling/fix/handle-cookie-banner-close
fix: clean up tracking modal usage to close it when accepted
2 parents da9702b + 11bf24c commit 04d4f4c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

app/root.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type {
33
LoaderFunctionArgs,
44
MetaFunction,
55
} from "@remix-run/node";
6-
import { json } from "@remix-run/node";
76
import {
87
Links,
98
Meta,
@@ -70,7 +69,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) {
7069
let { locale = "de" } = params;
7170
const cookieHeader = request.headers.get("Cookie");
7271
const cookie = (await gdprConsent.parse(cookieHeader)) || {};
73-
return json({ locale, track: cookie.gdprConsent });
72+
return { locale, track: cookie.gdprConsent };
7473
}
7574

7675
export function useChangeLanguage(locale: string) {
@@ -86,13 +85,11 @@ export default function App() {
8685

8786
useEffect(() => {
8887
setShouldTrack(track);
89-
}, []);
88+
}, [track]);
9089

91-
useEffect(() => {
92-
if (shouldTrack) {
93-
gtag.init();
94-
}
95-
}, [shouldTrack]);
90+
if (shouldTrack) {
91+
gtag.init();
92+
}
9693

9794
useChangeLanguage(locale);
9895

0 commit comments

Comments
 (0)