Skip to content

Commit f1d4a35

Browse files
committed
fix: update useEffect dependency to refresh ads on pathname change #18
1 parent 21a39e2 commit f1d4a35

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/AdUnit.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ export const AdUnit = ({
3636
}: AdUnitProps): JSX.Element | null => {
3737
const pathname = usePathname();
3838

39+
// biome-ignore lint/correctness/useExhaustiveDependencies: Refresh ads when pathname changes
3940
useEffect(() => {
4041
// biome-ignore lint/suspicious/noAssignInExpressions: adsbygoogle needed
4142
// biome-ignore lint/suspicious/noExplicitAny: needed to cast to any in order to access adsbygoogle
4243
((window as any).adsbygoogle = (window as any).adsbygoogle || []).push({});
43-
}, []);
44+
}, [pathname]);
4445

4546
const _publisherId =
4647
process.env.NEXT_PUBLIC_ADSENSE_PUBLISHER_ID ?? publisherId;

0 commit comments

Comments
 (0)