39 lines
818 B
TypeScript
39 lines
818 B
TypeScript
"use client"
|
|
|
|
import { useRef, useEffect, memo } from "react"
|
|
import IframeReference from "@/lib/4nk/IframeReference"
|
|
|
|
interface IframeProps {
|
|
iframeUrl: string
|
|
showIframe?: boolean
|
|
}
|
|
|
|
export const Iframe = memo(function Iframe({ iframeUrl, showIframe = false }: IframeProps) {
|
|
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}
|
|
style={{
|
|
display: showIframe ? 'block' : 'none',
|
|
width: '400px',
|
|
height: '400px',
|
|
border: 'none',
|
|
overflow: 'hidden'
|
|
}}
|
|
title="4NK Authentication"
|
|
/>
|
|
)
|
|
})
|