“Importowanie SVG do React” Kod odpowiedzi

Importowanie SVG do React

import React from 'react';
import { ReactComponent as BrandIcon } from "./assets/brand-icon.svg";

export default function(){
  return( 
      <div>
          <BrandIcon />
      </div>
   );
}
Adorable Anteater

Import SVG React

import React from 'react';
import LogoName from '../assets/logo.svg'

const Header = () => {
    return ( 
        <div>
           	<img src={LogoName} alt="logo"/>
        </div>
     );
}
Puzzled Puffin

importować SVG jako komponent React

import React from 'react';
import { ReactComponent as YourSvg } from './YourSvg.svg';

const MyComponent = () => {
    return(
        <YourSvg/>
    );
}

export default MyComponent ;
Captain Khaled

Konwertuj SVG na komponent React

//Use this WEB APP to convert any svg to a valide reactJs or React native Component
Playground - SVGR
https://react-svgr.com/playground/
SamuraiR4cc00n

Odpowiedzi podobne do “Importowanie SVG do React”

Pytania podobne do “Importowanie SVG do React”

Więcej pokrewnych odpowiedzi na “Importowanie SVG do React” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu