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
What if I render DOM using server side react? #49
Comments
They discuss about it here: but the Modal.injectCSS() still gave me problems, so I ended up doing this: var React = require('react');
var Modal = require('react-modal');
var ExecutionEnvironment = require('react/lib/ExecutionEnvironment');
if (ExecutionEnvironment.canUseDOM) {
Modal.injectCSS();
Modal.setAppElement(document.getElementById('react-app'));
}
... The server stopped crashing and it works on the frontend. |
Hi, I tried something like this,
but still it doesn't works,.. Regards. |
@eriknyk what is the error that you get with your code? |
I have not errors, just it doesn't works |
this happens just trying to run webpacked code server side:
|
Same error. Even with var ExecutionEnvironment = require('react/lib/ExecutionEnvironment'); if (ExecutionEnvironment.canUseDOM) { We are using server side rendering, so yes, document it's not defined on server. |
+1 for the same error on server side rendering. Would really love a fix for this. |
+1. Running into same issue on server side rendering |
+1 for same error with server side rendering. |
+1 over here for supporting server side rendering. If you need a short term solution you can downgrade to |
at the end I make it works, but without any styles,.. seems Modal.injectCSS(); is not working as expected or I need to add some stylesheets manually? |
This has been open for quite some time. Given the amount of people struggling with isomorphic rendering it's perhaps worth mentioning this library works client-side only in the project |
I didn't try it yet, but it seems that a PR was merged: #70 |
Server side rendering should be working with react-modal@0.6.0. Let me know if you have any issues. |
@mzabriskie can you be more specific, I am still experiencing this, what changed and is there an example somewhere I can look at? |
Just be clear, it doesn't throw any error, it just doesn't render the modal and I can't find any examples that show how to change the mount-point in a server-side compatible manner. |
// And when using document to get the dom element, server side won't support "document" object for the following code:
Modal.setAppElement(el);
Modal.injectCSS();
// I have also tried the following but It will prompt me about I need to insert element in that area
let el = React.findDOMNode(this.refs.cdrExportModal)
console.info('el', el)
Modal.setAppElement(el);
Modal.injectCSS();
Please help!
The text was updated successfully, but these errors were encountered: