Skip to content

Commit

Permalink
chore: add pathname as deps when pushing ads
Browse files Browse the repository at this point in the history
  • Loading branch information
joshxfi authored Mar 9, 2024
2 parents 0a31a42 + 0afe961 commit 91c08ea
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/web/src/components/AdContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect } from 'react';
import { twMerge } from 'tailwind-merge';
import { useRouter } from 'next/router';

interface Props {
slotId: string;
Expand All @@ -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 (
<div className={twMerge(className, test && 'h-24 bg-blue-200')}>
Expand Down

0 comments on commit 91c08ea

Please sign in to comment.