jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

ReferenceError: React is not defined #14

Closed ianwalter closed 8 years ago

ianwalter commented 8 years ago

When I try to use this loader to load a SVG file I get this error:

ReferenceError: React is not defined
    at Object.<anonymous> (/Users/ian/boyscout/site/svg/link-icon.svg:1:1)
    at Module._compile (module.js:425:26)
    at normalLoader (/Users/ian/boyscout/node_modules/babel-core/lib/api/register/node.js:199:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/ian/boyscout/node_modules/babel-core/lib/api/register/node.js:216:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/ian/boyscout/site/components/index.js:2:28)
    at Module._compile (module.js:425:26)

I'm using react@0.14.7, webpack@1.12.13, babel@5.8.35 and I've tried both 0.3.1 and 0.3.2 of this loader. I've also tried messing with externals and other shots in the dark but I haven't been able to get it working. Btw, repo is at github.com/ianwalter/boyscout#v0.4.0 (but it became kind of a mess when debugging). Any help would be immensely appreciated.

jhamlet commented 8 years ago

Which version of node and npm are you running?

I'm in the middle a road trip, so I probably won't be able to tackle this right away.

ianwalter commented 8 years ago

Node v5.1.1 and NPM 3.3.12. No problem, I'm sick anyway, but I appreciate the quick response.

ianwalter commented 8 years ago

Sorry for the noise, this happened because I was requiring a component in the node build process outside of Webpack. Closing.

tconroy commented 8 years ago

Hi @ianwalter -- think I may be running into a similar issue ( #31 ) -- was wondering if you could elaborate a bit more on what fixed it for you?