import React , { ReactNode , useState } from 'react' ; import { useEffect } from 'react' ; import { createPortal } from 'react-dom' ; export function Portal ( props ) { let { children } = props ; let [ mounted , setMounted ] = useState ( false ) ; useEffect ( ( ) => setMounted ( true ) , [ ] ) ; if ( ! mounted ) return null ; return createPortal ( children , document . body ) ; }