mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-06-03 15:07:00 +00:00
26 lines
502 B
TypeScript
26 lines
502 B
TypeScript
import React, { useEffect, useState } from 'react'
|
|
import { createPortal } from 'react-dom'
|
|
|
|
interface PortalProps {
|
|
children: React.ReactNode
|
|
}
|
|
|
|
const Portal: React.FC<PortalProps> = ({ children }) => {
|
|
const [mounted, setMounted] = useState(false)
|
|
|
|
useEffect(() => {
|
|
setMounted(true)
|
|
|
|
return () => setMounted(false)
|
|
}, [])
|
|
|
|
return mounted
|
|
? createPortal(
|
|
children,
|
|
document.querySelector('#modal-root') as HTMLElement
|
|
)
|
|
: null
|
|
}
|
|
|
|
export default Portal
|