Import SVGs as React Components -Tutorial by DevDone. – Rishi Jodha

0
50
Import SVGs as React Components -Tutorial by DevDone. - Rishi Jodha


Embedding SVGs as React components rather than <img> tags.

Svgs today are an integral part of web development giving abilities scale images without losing the quality. Importing SVG files as img tags have a few limitations.

  • ✔️ Size reduction: The conversion to ReactComponent is smaller than the SVG itself.
  • ✔️ Since it’s a component, therefore, easy to use and handle and rendered inline therefore we can control it easily.
  • ✔️ SVG images bundled with JS, therefore no extra fetch browser calls, not even SVG Sprites needed.
  • ✔️ Converting SVG to a component can be helpful in customizing the images.



Source link

Leave a reply

Please enter your comment!
Please enter your name here