Skip to content

Instantly share code, notes, and snippets.

View mikkel's full-sized avatar

mikkel mikkel

View GitHub Profile
@mikkel
mikkel / svgImage.js
Last active September 12, 2019 05:16
Import an SVG file into your DOM with React and ES6. Useful for manipulating internal path elements. Only use trusted sources.
var React = require('react');
class SvgImage extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
componentDidMount() {
$.get(this.props.url, (svg) => {
this.setState({icon: svg.documentElement.outerHTML});
});