Portal children cannot access the DOM in useEffect / componentDidMount
wilcoxmd opened this issue · 1 comments
wilcoxmd commented
Describe the bug
Because the the portal element is appended to the DOM in useEffect, on the initial render, the portal is created in a detached DOM node. It's children render and run their useEffects first, and any access to the DOM will not work.
Codesandbox
https://codesandbox.io/s/objective-keldysh-0078v?file=/src/App.js
To Reproduce
Steps to reproduce the behavior:
- try to reference the DOM in a child of the Portal within useEffect or componentDidMount (or just checkout the codesandbox)
Expected behavior
The Portal doesn't render the children until it has attached the root element to the DOM
wilcoxmd commented
as another comment... i didn't mean to assign you directly. that was either accidental or an automation. Not an attempt to be aggressive. Sorry! :D