-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Bug] Doesn't work with imported SVGs #63
Comments
Seems like it's not possible to iterate over react children (nested elements of svg) for imported svgs. Not sure what can be done about that. |
It's a hack but I've found a workaround for this. import MySVG from '-!react-svg-loader!./mysvg.svg';
// Little hack around the imported svg to get at the SVG react/jsx elements.
const UniqueSVG = ({svg}) => (
<SVGUniqueID>
{React.createElement(svg).type({ styles: {} })}
</SVGUniqueID>)
// ...Then somewhere in your render:
<UniqueSVG svg={MySVG}/> That's it. |
I don't use this library anymore and have no interest in fixing/updating it. If someone creates a pull request with a working fix I will be willing to merge it. |
I have another “hack” suggestion that worked for me. import { SVGUniqueID } from 'react-svg-unique-id'
import myicon from './myicon.svg'
const MyIcon = (props) => {
return <SVGUniqueID>{myicon(props)}</SVGUniqueID>
} |
Hi,
I'm having trouble getting the plugin to work with imported SVGs e.g.
However it works when the SVG is inlined.
You can view a demo of the problem here:
The text was updated successfully, but these errors were encountered: