feat: unique tagging

This commit is contained in:
TrèsAbhi committed 2024-06-10 14:10:58 -05:00
1 parent 1e36a24aff
commit fa4c1cea56
1 file changed
+9 -3
+9 -3
View File
@@ -1,6 +1,7 @@
'use client'; 'use client';
import { ComponentProps, useEffect } from 'react'; import { uniqueId } from 'lodash';
import { ComponentProps, useEffect, useRef } from 'react';
export enum AdType { export enum AdType {
TankopediaHorizontal800 = 738182777, TankopediaHorizontal800 = 738182777,
@@ -11,11 +12,16 @@ interface AdProps extends ComponentProps<'div'> {
} }
export function Ad({ type, ...props }: AdProps) { export function Ad({ type, ...props }: AdProps) {
const id = useRef(uniqueId());
useEffect(() => { useEffect(() => {
(window as any).msAdsQueue.push(function () { (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 <div id={`${type}`} {...props} />; return <div id={`${type}-${id.current}`} {...props} />;
} }