-
Notifications
You must be signed in to change notification settings - Fork 810
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
Server-side rendering (SSR) #580
Comments
For reference, since it was a pain for me, if you are doing SSR, use the following code to prevent errors server-side:
You could put this in |
@NathanielHill It can be a nice solution. We have |
Hey, I added a pr that might be also relevant for this issue: #668 |
Awesome @lbelinsk, was going to do this any day now... 🤣 Thanks for taking care of it! 🎉 |
My pleasure @NathanielHill :) |
Released v3.4.5. Thanks, @lbelinsk! |
Does this mean the modal now gets rendered for SSR? Can we improve the docs to mention what the support is? |
@OliverJAsh whether it gets rendered on the server would have to do with your own code. By the nature of what a "modal" is, I doubt it would normally be rendered server-side since modals are triggered by client interaction. This is just a guard against getting errors from code that tries to reference the |
@OliverJAsh I think it will be better to follow the conversation in this issue instead: It is still open just in order to remember to add docs for ssr support. |
Found myself asking the same question ("what is the SSR support"?), but unfortunately there still aren't docs to cover this, so I'll try to provide a summary of what I've inferred (for future me and others, in absence of docs): The modal uses React portals. Portals only work on the client-side, because they need a DOM element. For this reason, the modal is not rendered on the server. react-modal/src/components/Modal.js Lines 195 to 196 in a2838bb
If we wanted to enable rendering of the modal on the server, we would have to use an alternative portal mechanism. This was proposed in #112, but it seems the proposal did not receive enough attention, and the issue was closed.
Modals can have URLs too, so they can be triggered just by navigating to a URL. For this reason, we would like the modal to support SSR, so that the modal works without JS and before JS loads. |
It would be good to add a warning when the modal is rendered in SSR, because right now it silently fails. |
Hi,
I have searched the issues and docs to try and understand what the current status of support for server-side rendering is, however it is not clear.
Underneath the
App Element
heading, the docs mention:Can you elaborate?
Related issues: #112 #362 #49 #576
Is server-side rendering something that is already supported, or will be in the future?
Thanks,
Oliver
The text was updated successfully, but these errors were encountered: