From 0afe96186432eaaed0ffae620c3cadb24c6ac6e1 Mon Sep 17 00:00:00 2001 From: Josh Daniel Date: Sat, 9 Mar 2024 13:38:55 +0800 Subject: [PATCH] chore: add pathname as deps when pushing ads --- apps/web/src/components/AdContainer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/components/AdContainer.tsx b/apps/web/src/components/AdContainer.tsx index 58c0acd5..04f26fbc 100644 --- a/apps/web/src/components/AdContainer.tsx +++ b/apps/web/src/components/AdContainer.tsx @@ -1,5 +1,6 @@ import React, { useEffect } from 'react'; import { twMerge } from 'tailwind-merge'; +import { useRouter } from 'next/router'; interface Props { slotId: string; @@ -8,11 +9,13 @@ interface Props { } const AdContainer = ({ slotId, className, test }: Props) => { + const router = useRouter(); + useEffect(() => { if (process.env.NODE_ENV === 'production' && typeof window === 'object') { (window.adsbygoogle = window.adsbygoogle || []).push({}); } - }, []); + }, [router.pathname]); return (