-
Notifications
You must be signed in to change notification settings - Fork 937
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
ReactDOM is not defined server side by default #186
Comments
I went through all this too for several days with Browserify, in the end I just included React in my bundle (via Webpack which is far easier to use and reason about than Browserify). I understand this might not be ideal (which is why I worked on it for days) but in the end it solved a lot of my issues. Is that something you can do? |
I might be able to pack react-dom into my bundle, only React needs to be in he global scope. I will try that on monday. The woraround I mention works fine too, it is just ugly. |
How are you loading React? If you're loading it from a CDN, you just need to load ReactDOM in addition to React:
|
On the client side I'm referencing react.js and react-dom.js locally. On the server side I'm using whatever ReactJS.NET uses by default. My issue is only a server-side one. I'll explain it in more detail on monday since it's on my work machine. |
ReactDOM shouldn't be used server-side, it's only for client-side stuff. Perhaps something is unintentionally using it server-side. Are you able to provide a stack trace of the error you're encountering? |
It is used by the modal component of react-bootstrap. There is a |
To be honest I think your workaround is fine for now, even with the scary I'll probably end up doing something like this in
as this matches up with what react-dom.js on the CDN does. At which point you could do |
@PeteDuncanson How were you able to avoid an invariant violation/"multiple copies of React error" doing it that way (since you'll need to import React/ReactDOM again to get the client-side working)? Nevermind, I imagine you exposed them via webpack. That seems to work. |
I'm using React.NET with Webpack.
The internals of my
ReactConfig
:The server bundle does not contain React. Therefore I put this in my
webpack.config.js
:ReactDOM is undefined on the serverside.
The workaround will get me fired :(
The text was updated successfully, but these errors were encountered: