Create React App에서 SVG 파일을 간단히 불러오는 방법

공부는 혼자하는 거·2021년 8월 21일
0

React Tip

목록 보기
3/24

아래와 같이 불러오면 컴포넌트처럼 활용할 수 있다.

import React from 'react';
import { ReactComponent as Arrow } from '../assets/icons/arrow.svg';

const App = () => {
  return (
    <div>
      <Arrow fill="#0079ff" width="14" height="14" />
    </div>
  );
};

arrow.svg를 ReactComponent로 불러오고 이름을 Arrow로 바꿔서

fill이나 width 같은 속성을 넣을 수도 있다.

profile
시간대비효율

0개의 댓글