Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portal children cannot access the DOM in useEffect / componentDidMount #52

Open
wilcoxmd opened this issue May 12, 2020 · 1 comment
Open
Assignees

Comments

@wilcoxmd
Copy link

wilcoxmd commented May 12, 2020

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:

  1. 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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants