-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
Skip portals when rendering on server-side. #12278
Skip portals when rendering on server-side. #12278
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Would you mind rebasing this PR on top of master? Then we can figure out how to merge this :) |
@cpojer Done. |
The idea is to just skip the rendering of portals. This would allow the usage of `createPortal` if present in the components tree.
React: size: 🔺+0.7%, gzip: 🔺+0.3% Details of bundled changes.Comparing: cc5a493...2509074 react
Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to skip them. You can't render a portal without a DOM container element regardless. Therefore, the application code should skip them anyway.
The original behavior was intentional, and it's not clear to me why it is being removed here.
This is an old patch. Not sure if it is relevant now or there are things to change. I believe most implementations that uses IMHO, since portals can't be rendered on server-side, I don't know if throwing an exception is desired and will make all libraries to check for DOM environment. Making portal a no-op seems ok. Perhaps, display a warn when trying to render? |
To provide more context, one of the reasons why Material-UI has a Portal component is to avoid the server-side error. |
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution. |
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you! |
Hi,
Here is an option that just skips portals while rendering on the server-side environment.
I'll try to find some ideas to help dealing with modals on tests.
Please let me know if there are any improvements in this PR.
If the solution is not ideal, it can be closed.
Thank you.