-
Notifications
You must be signed in to change notification settings - Fork 82
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
"Reference Error: React is not defined" with server side rendering. How to implement in an isomorphic context? #31
Comments
Any ideas? Think the root issue is it's unclear how to implement this in an isomorphic (server side) environment. |
@tconroy can you get a look at the transpiled source of |
@jhamlet sure -- I believe this is it, ripped from the bundle file (please let me know if you need any more samples :) ):
|
Interesting. You're getting the error on the In that same source what is Are you using React in other places (again, I would assume so)? Are they pulling in the same module number (11)? Something to try: In your var React = require('react'); |
@jhamlet: first off -- thank you for your help. hope we can solve this!
I've added in an example implementation to my original post (at the end) showing how I'm actually using the SVG inside a component ( pretty basic ). Adding the React require to |
so some minor clarification / correction on my part: The error is occurring when I try to run our
We have a separate build command,
I'm not sure how to provide the transpiled source for |
Interesting. Are you pre-compiling with |
Not sure what to say, or where to go from here... Is it possible you can create a stripped-down version of your project that reproduces this issue? With that I can then do some debug-runs on my end. |
Hi @jhamlet -- no, no pre-compiling with webpack prior to this step. I will try and create a stripped down version when I have some time this weekend. Thank you for your help. |
@tconroy on another note: I'm getting ready to publish v0.4.0 as latest. You can try it out with |
@jhamlet good to know, thanks. I'll give it a shot. My guess was this issue was being caused somewhere in the babel transpiration so maybe that'll help. For the time being I had to unfortunately remove the loader from the project but really hoping to add it back since it works so well. |
@tconroy Any progress on this? Did v0.4.0 solve the problem? Did you get the chance to create a smaller sample repo that reproduces the issue? |
hi @jhamlet -- apologies for the delay, been busy and haven't gotten around to this since removing from the project. will keep you posted! |
Hi @jhamlet - First off, thank you for your efforts on this loader! I am getting this same error when running tests with Mocha. My Mocha config is
It doesn't happen when running the application, just the tests. Version 0.4.0-beta2 didn't fix the issue. Just wondering if you had had any further thoughts on this issue since August? Thanks very much :) |
OK, I worked it out. When testing with Mocha, it's not even using the webpack config. So mocha on it's own just doesn't know how to handle a raw SVG file being imported as it isn't a javascript file. I don't quite understand why it was failing on Either way, I found 2 ways around it. Option 1 is to use Option 2 is what I have done and is to remove the SVG extension from those that are imported with mocha and use
|
meet this problem,try:
|
Thanks @onvno! |
Hi there. I don't use
Webpack config:
jsx-1:
jsx-2:
Any help would be extremely appreaciated. |
Here is reproducible example https://github.com/stereobooster/comparison/tree/aphrodite-ssr
Also requires babel-node (facepalm) |
@onvno Yep, it's working |
Similar issue with |
excuse me, can you tell me the reason |
Hi!
This is likely just a configuration issue on my part, but I'm getting the following error message when attempting to use this loader in an isomorphic react app:
error:
webpack loader config:
contents of SVG file:
simplified example of how the SVG is being imported:
The setup instructions I followed were from this guide (method 2)
Environment is:
Node: 5.5.0
NPM: 2.15.9
Webpack: 1.13.1
React: 0.14.0
svg-react-loader: 0.3.7
Express: 4.14.0
A coworker had this working on his local via a simple
webpack-dev-server
, however while attempting to implement it into an isomorphic react context (express server backened), I am now getting this error.If you need any other info from me please feel free to ask. Any help much appreciated.
The text was updated successfully, but these errors were encountered: