Using SVGs
In this section, we will learn how to use SVG files in React and how to use them for the icons in the alert component.
Understanding how to use SVGs in React
SVG stands for Scalable Vector Graphics and it is made up of points, lines, curves, and shapes based on mathematical formulas rather than specific pixels. This allows them to scale when resized without distortion. The quality of icons is important to get right – if they are distorted, they make the whole app feel unprofessional. Using SVGs for icons is common in modern web development.
Create React App configures webpack to use SVG files when a project is created. In fact, logo.svg
is referenced in the template App
component as follows:
import logo from './logo.svg'; ... function App() { return ( <div className="App"> <header className="App-header"> ...