From fa4c1cea56697fb50ea0d6931e1f1201e9df3446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 10 Jun 2024 14:10:58 -0500 Subject: [PATCH] feat: unique tagging --- src/components/Ad.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Ad.tsx b/src/components/Ad.tsx index d303ee603..afa0cc654 100644 --- a/src/components/Ad.tsx +++ b/src/components/Ad.tsx @@ -1,6 +1,7 @@ 'use client'; -import { ComponentProps, useEffect } from 'react'; +import { uniqueId } from 'lodash'; +import { ComponentProps, useEffect, useRef } from 'react'; export enum AdType { TankopediaHorizontal800 = 738182777, @@ -11,11 +12,16 @@ interface AdProps extends ComponentProps<'div'> { } export function Ad({ type, ...props }: AdProps) { + const id = useRef(uniqueId()); + useEffect(() => { (window as any).msAdsQueue.push(function () { - (window as any).mmnow.render({ adUnitId: type, elementId: type }); + (window as any).mmnow.render({ + adUnitId: type, + elementId: `${type}-${id.current}`, + }); }); }); - return
; + return
; }