Skip to content

Commit

Permalink
portal: fix TypeError when using hot-loader (#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
jylertones committed May 6, 2020
1 parent 25840c3 commit e0e1b09
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/portal/src/index.tsx
Expand Up @@ -26,6 +26,8 @@ const Portal: React.FC<PortalProps> = ({ children, type = "reach-portal" }) => {
let [, forceUpdate] = useState();

useIsomorphicLayoutEffect(() => {
// This ref may be null when a hot-loader replaces components on the page
if (!mountNode.current) return;
// It's possible that the content of the portal has, itself, been portaled.
// In that case, it's important to append to the correct document element.
const ownerDocument = mountNode.current!.ownerDocument;
Expand Down

0 comments on commit e0e1b09

Please sign in to comment.