-
Notifications
You must be signed in to change notification settings - Fork 45.7k
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
createPortal fails silently if used outside or render method #12653
Comments
It's no different from how JSX and |
If the docs aren't clear please raise an issue in https://github.com/reactjs/reactjs.org or send a PR to improve them. Thank you! |
@gaearon , How would one use My use case is very similar to this comment. I have a vanilla JS library that generates DOM Nodes by parsing a JSON object. I've used |
I updated a package to work with react 16.3.2.
unstable_renderSubtreeIntoContainer
was used there. When I replaced it withcreatePortal
, nothing happened and no errors were displayed. I wasted several hours to understand thatunstable_renderSubtreeIntoContainer
could be used anywhere, for example incomponentDidUpdate
(as it was in my case). ButcreatePortal
can be used only inrender
. So it would be great to have a warning when it is used outside render to let people know what they are doing wrong. And maybe consider adding a note on this in the docs. Thanks.The text was updated successfully, but these errors were encountered: