jhamlet / svg-react-loader

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

Using the loader in a lib causes `You've loaded two copies of React on the page.` #30

Closed ghost closed 8 years ago

ghost commented 8 years ago

When I use svg-react-loader in a library which I pack with webpack, the user using this package gets:

Warning: React can't find the root component node for data-reactid value .0.0.1.0.0.1.0.0.1.0.1.1.2.1.0.0. If you're seeing this message, it probably means that you've loaded two copies of React on the page. At this time, only a single copy of React can be loaded at a time.

If I remove the SVG components, it works fine.

I import them like this:

  Pic = require('babel!svg-react!./assets/pic.svg?name=Pic')

Using them within a project (not via a lib) works fine.

jhamlet commented 8 years ago

Can you describe what you mean by a "lib"?

If you mean something similar to an npm package, with its own dependencies, I can see how that could cause a problem. Is this library also depending on React?

ghost commented 8 years ago

yes. I resolved by declaring react as an external in webpack. :)