Skip to content

Instantly share code, notes, and snippets.

@trinadhkoya
Created December 25, 2018 14:42
Show Gist options
  • Save trinadhkoya/44a56d7181876aac938c98a1004bd001 to your computer and use it in GitHub Desktop.
Save trinadhkoya/44a56d7181876aac938c98a1004bd001 to your computer and use it in GitHub Desktop.
Convert SVG code to JS code with Dynamic Props
import React from 'react'
import PropTypes from 'prop-types';
import Svg, {G, Path} from "react-native-svg";
class ImageIco extends React.Component {
constructor(props) {
super(props);
}
render() {
const {width, height, fill, viewBox} = this.props;
return (
<Svg viewBox={viewBox}
width={width} height={height}><G transform="matrix(1 0 0 1 0 0)"><G>
<Path
d="M283,3H30C13.458,3,0,16.458,0,33v247c0,16.542,13.458,30,30,30h253c16.542,0,30-13.458,30-30V33 C313,16.458,299.542,3,283,3z M283,33l0.01,131.228l-50.683-47.598c-3.544-3.327-8.083-5.159-12.78-5.159 c-5.715,0-11.063,2.681-14.673,7.354l-59.663,77.256c-1.934,2.504-5.036,3.999-8.299,3.999c-2.223,0-4.324-0.676-6.076-1.956 l-38.773-28.316c-3.862-2.821-8.865-4.374-14.085-4.374c-5.945,0-11.504,1.938-15.65,5.456L30,198.31V33H283z"
fill={fill}/>
<Path d="M115,122c17.093,0,31-13.907,31-31s-13.907-31-31-31S84,73.907,84,91S97.907,122,115,122z"
fill={fill}/>
</G>
</G>
</Svg>
)
}
}
ImageIco.propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
viewBox: PropTypes.string.isRequired
};
ImageIco.defaultProps = {
width: 24,
height: 23,
stroke: '#fff',
fill: '#fff',
viewBox: '0 0 25 25'
};
export default ImageIco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment