4 ms·
We use SVG as react components to change SVG attributes without the need to change the SVG source, e.g. the color of the icons etc
by bromuro 9y ago
We use SVG as react components to change SVG attributes without the need to change the SVG source, e.g. the color of the icons etc
- kuschku 9y agoYou know you can use CSS and JS for that?
- rmetzler 9y agoHow would I go to represent rectangles, circles, text and lines with CSS and JavaScript? With Canvas? Is React able to render to canvas? Sometimes SVG is a good fit for the graphics needed.
- kuschku 9y agoI meant styling the SVG — instead of replacing SVG with react (slow), use CSS to modify properties of the SVG DOM. That is significantly faster.
- bromuro 9y ago> You know you can use CSS and JS for that? No, I didn't. Thanks. /s There are many cases it's more convenient updating SVG using React.
- kuschku 9y agoOf course it is more convenient, but it's also several orders of magnitude slower. If you try rendering, say, maps with SVG, this becomes a significant issue.