forked from 77media/video-flow
- Fixed TypeScript compilation error in createPortal function - Added type assertion to resolve React type definition conflicts - Ensures successful build process for deployment
22 lines
433 B
TypeScript
22 lines
433 B
TypeScript
import { useEffect, useState } from 'react';
|
|
import { createPortal } from 'react-dom';
|
|
|
|
interface PortalProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
export function Portal({ children }: PortalProps) {
|
|
const [mounted, setMounted] = useState(false);
|
|
|
|
useEffect(() => {
|
|
setMounted(true);
|
|
return () => setMounted(false);
|
|
}, []);
|
|
|
|
if (!mounted) return null;
|
|
|
|
return createPortal(
|
|
children as any,
|
|
document.body
|
|
);
|
|
} |