diff --git a/components/ui/dialog.tsx b/components/ui/dialog.tsx index d9aecca..e77429e 100644 --- a/components/ui/dialog.tsx +++ b/components/ui/dialog.tsx @@ -22,6 +22,15 @@ function DialogTrigger({ function DialogPortal({ ...props }: React.ComponentProps) { + // Radix's Portal calls createPortal(children, document.body) as soon as it + // renders. During static prerendering there's no `document`, so gate the + // portal behind an effect that only runs in the browser. Closed dialogs + // render nothing on the server anyway, so there's no visual/hydration change. + const [mounted, setMounted] = React.useState(false) + React.useEffect(() => setMounted(true), []) + + if (!mounted) return null + return }