2025-10-20 12:29:33 +02:00

27 lines
694 B
TypeScript

import { useRef, useEffect, memo } from 'react';
import IframeReference from '@/lib/4nk/IframeReference';
function Iframe({ iframeUrl, showIframe = false }: { iframeUrl: string; showIframe?: boolean }) {
const iframeRef = useRef<HTMLIFrameElement>(null);
useEffect(() => {
if (iframeRef.current) {
IframeReference.setIframe(iframeRef.current);
}
return () => {
IframeReference.setIframe(null);
};
}, [iframeRef.current]);
return (
<iframe
ref={iframeRef}
src={iframeUrl}
className={`${showIframe ? 'block' : 'hidden'} w-96 h-96 border-none overflow-hidden`}
/>
);
}
Iframe.displayName = 'Iframe';
export default memo(Iframe);