Created
February 14, 2021 13:36
-
-
Save merksam/b7bdfe9f1131ffb678c159f200350759 to your computer and use it in GitHub Desktop.
Article / SVG Icons React / Icon.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cn from 'classnames'; | |
import * as React from 'react'; | |
import './Icon.sass'; | |
type Props = { | |
name: string, | |
} | |
export const Icon = (props: Props) => { | |
const { name } = this.props; | |
const icon = require(`./${name}.svg`); | |
return ( | |
<span | |
onClick={onClick} | |
className={cn('icon', `icon-${name}`)} | |
dangerouslySetInnerHTML={{ __html : icon.default }} | |
/> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment