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
Incompatible with server-side rendering #15
Comments
How about including this into your app? HTMLElement = typeof HTMLElement === 'undefined' ? function(){} : HTMLElement;
var appElement = ENV.CLIENT ?
document.getElementById('appElement') :
new HTMLElement(); |
I could do that (plus shim document.body.etc - HTMLElement is just the first choke point), but I'd have to run a hacked version of this package rather than just put that in my app, and I'd prefer not to do that. I could also possibly just require react-modal on the client-side and pass either it or a server-side alternative element all the way down my app hierarchy, but... come on. Plenty of people are running React trees in Node; it'd be nice to have a modal library that didn't require all that ducking and weaving. |
I had a little peek at wrapping the offending bits in ExecutionEnvironment.canUseDOM but I could not really think up a good way to do portals without the dom. |
Could you post a gist? I'm pretty sure I don't need the things to work on the server... I just need them to not crash the server. |
@misuba this is crude and untested, just designed to give you the idea, https://gist.github.com/nelix/24dd21b12d4b005880aa you could also not mess with react-modal at all and just render null instead if the dom is not available, but I think we could come up with a server render alternative that mostly works instead of these hacks |
With the @nelix 's gist augmented with the @ryanflorence 's workaround ( Can we considered the issue as solved and make a new release ? :) |
👍 |
1 similar comment
I wonder if the work from BedrockStreaming#1 could be merged into this repository? I've just tried it and it works fine when rendering React on server for me. |
Resolved with #22 |
A source tree with react-modal in it, running in Node, yields the following:
...and halts entirely.
How would you feel about making this propType a little more lenient (
object
, perhaps)?The text was updated successfully, but these errors were encountered: