import React , { ReactNode , useContext } from 'react' ; import { PortalContext } from './context' ; const Portal = ( { children } ) => { const portalContext = useContext ( PortalContext ) ; if ( ! portalContext ) { throw new Error ( 'Cannot found `portalContext`. This might be an internal error in GojiJS.' ) ; } return portalContext . createPortal ( children ) ; } ; export const createPortal = ( element , key ? ) => ( < Portal key = { key ?? String ( key ) } > { element } < /Portal>); export { PortalContext } from './context' ; export { PortalProvider } from './provider' ;