From 53dee89fcaf31469780f4fa9e12719e66df07919 Mon Sep 17 00:00:00 2001 From: paufau Date: Tue, 8 Sep 2026 10:21:23 +0400 Subject: [PATCH] feat(web): guard document from being accessed by ssr --- src/ModalView.web.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ModalView.web.tsx b/src/ModalView.web.tsx index 09efe10..944c602 100644 --- a/src/ModalView.web.tsx +++ b/src/ModalView.web.tsx @@ -64,6 +64,13 @@ export const ModalView: FC = ({ }; }, [isTopmost, onRequestDismiss]); + // renders nothing on server side + // typically "document" is undeclared on the server + // and "typeof" can safely touch undeclared variables without throwing + if (typeof document === 'undefined') { + return null; + } + return createPortal(