Skip to content

Instantly share code, notes, and snippets.

@merksam
Created February 14, 2021 13:36
Show Gist options
  • Save merksam/b7bdfe9f1131ffb678c159f200350759 to your computer and use it in GitHub Desktop.
Save merksam/b7bdfe9f1131ffb678c159f200350759 to your computer and use it in GitHub Desktop.
Article / SVG Icons React / Icon.tsx
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