---
title: "Comment by Yury on \"How to use SVG's in React\" | Hashnode"
description: "Probably not worth my time to write this but i wanted to try out the editor (and it&#39;s buggy lol) Basically, don&#39;t ever do this unless you are actually u"
url: "https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6/comment/6016d77313f0a55761bdf233"
---

[Discussion](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6)

Comment [How to use SVG's in React](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6)

[Yury](https://hashnode.com/@lol)

[Jan 31, 2021](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6/comment/6016d77313f0a55761bdf233)

Probably not worth my time to write this but i wanted to try out the editor (and it's buggy lol)

Basically, don't ever do this unless you are actually using dynamic svg in your project. Your code is not reusable and also I think this probably adds more unnecessary computation because react has to diff the dom tree and your complex svg logo data props are now part of that dom tree.

99.9% of the time, you are better off just dropping the svg icon file that you downloaded from the webz into some folder and using a webpack SVG loader. Then, you can simply pass in a custom css `fill` style property to the icon component to change its color or w/e.

Install webpack svg loader

```
npm install @svgr/webpack
```

Update your webpack config

```
{
 test: /\.svg$/,
 use: ['@svgr/webpack']
},
```

Import icons and render them

```
import i_react from './icons/react-icon.svg'
....
<i_react style={fill:"red"}/>
```

that's literally all you have to do.

[Yury](https://hashnode.com/@lol)

[Jan 31, 2021](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6/comment/6016d77313f0a55761bdf233#reply-6016d8d213f0a55761bdf248)

( u can still use react `memoization` to skip rendering the react rendered svg, but don't do that lol )

[Emin Aydin](https://hashnode.com/@codinghistorian)

[Jan 31, 2021](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6/comment/6016d77313f0a55761bdf233#reply-601719206f46cc1ff950a82d)

Hey [Yury](https://hashnode.com/@lol),

Thanks a lot for taking the time to reply!

I find it hard to understand how you think the code is not reusable since I literally re-used it there. As you have mentioned, my solution would cause more computation but I would argue if it is unnecessary.

Even though your approach is completely valid, once you need to have more access to the SVG properties, it is not satisfying at all. So it is completely developers responsibility to decide on which way to follow, depending on how they are going to use SVG files in their project. But once again thanks for taking the time and coming up with another approach, I really appreciate it :)

[Yury](https://hashnode.com/@lol)

[Feb 1, 2021](https://hashnode.com/posts/how-to-use-svgs-in-react/600d89133fdbb7412625f9c6/comment/6016d77313f0a55761bdf233#reply-6017a0dba4a28d1fcefce35d)

[Emin Aydin](https://hashnode.com/@codinghistorian)

Okay sorry, let me clarify. I was just going off of your example, where you only changed the color. This is what most devs (like 99%) will probably do for which you can simply use svg css styling, that is why you would want to treat it like a _reusable icon_

However.... if you indeed want to animate custom svg properties for your logo, I would suggest you use an appropriate library because animating svg props manually without abstractions (like relative positioning and data attributes) is not for beginners ;)

hope this helps! :)
