Skip to content

Instantly share code, notes, and snippets.

@sephi-dev
Created May 3, 2018 14:58
Show Gist options
  • Save sephi-dev/6bb04165a91913edcc3b7783a407d6d1 to your computer and use it in GitHub Desktop.
Save sephi-dev/6bb04165a91913edcc3b7783a407d6d1 to your computer and use it in GitHub Desktop.
import React from "react";
import PropTypes from "prop-types";
import sprite from "./assets/sprite.svg";
const defaultStyle = {
fill: "#000",
width: "25px",
height: "25px"
};
const Svg = ({ style, id }) => (
<svg style={style ? style : defaultStyle}>
<use xlinkHref={`${sprite}#${id}`} aria-hidden="true" />
</svg>
);
Svg.propTypes = {
style: PropTypes.shape({}),
id: PropTypes.string.isRequired
};
Svg.defaultProps = {
style: null
};
export default Svg;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment