diff --git a/packages/portal/src/index.tsx b/packages/portal/src/index.tsx index 21492afb2..77863f5c8 100644 --- a/packages/portal/src/index.tsx +++ b/packages/portal/src/index.tsx @@ -26,6 +26,7 @@ const Portal: React.FC = ({ children, type = "reach-portal", containerRef, + unstable_skipInitialRender, }) => { let mountNode = React.useRef(null); let portalNode = React.useRef(null); @@ -72,6 +73,15 @@ const Portal: React.FC = ({ }; }, [type, forceUpdate, containerRef]); + let [hydrated, setHydrated] = React.useState(false); + React.useEffect(() => { + setHydrated(true); + }, []); + + if (unstable_skipInitialRender && !hydrated) { + return; + } + return portalNode.current ? ( createPortal(children, portalNode.current) ) : ( @@ -103,6 +113,7 @@ type PortalProps = { * @see Docs https://reach.tech/portal#portal-containerRef */ containerRef?: React.RefObject; + unstable_skipInitialRender?: boolean; }; if (__DEV__) {