refactor: mobile modals (#2173)
This commit is contained in:
@@ -3,11 +3,12 @@ import { createPortal } from 'react-dom'
|
||||
|
||||
type Props = {
|
||||
children: ReactNode
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const randomPortalId = () => Math.random()
|
||||
|
||||
const Portal = ({ children }: Props) => {
|
||||
const Portal = ({ children, disabled = false }: Props) => {
|
||||
const [container, setContainer] = useState<HTMLElement>()
|
||||
|
||||
useEffect(() => {
|
||||
@@ -18,6 +19,10 @@ const Portal = ({ children }: Props) => {
|
||||
return () => container.remove()
|
||||
}, [])
|
||||
|
||||
if (disabled) {
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
return container ? createPortal(children, container) : null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user