Last active
May 16, 2024 12:17
-
-
Save chichilatte/d1a796db707dff1dac77b81815c47ef4 to your computer and use it in GitHub Desktop.
Importing an SVG as a React component (mid 2024)
This file contains hidden or 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
declare module "*.svg" { | |
const ReactComponent: React.FunctionComponent<React.SVGAttributes<SVGElement>>; | |
export {ReactComponent}; | |
} |
This file contains hidden or 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 {ReactComponent as PencilIcon} from '../assets/icons/pencil.svg' | |
export default function EditButton(onClick:() => void) { | |
return <button onClick={onClick}> | |
<PencilIcon width="12" /> | |
</button> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment