Re:Transform SVG into React components
by bromuro on Monday October 30, 2017 @05:51AM
(#15583920)
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
[ Parent
| on HN ]
You know you can use CSS and JS for that?
> 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.
Of 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.
How 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.