“importar svg react” Código de respuesta

Importar SVG en React

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

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

importar svg react

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

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

Cómo importar SVG en React

//customIcon.js

import React from "react";
import {ReactComponent as ImportedSVG} from "path/to/myIcon.svg";
import { SvgIcon } from '@material-ui/core';

function CustomIcon() {
 return(
  <SvgIcon component={ImportedSVG} viewBox="0 0 384 512"/>

)
}

export default CustomIcon;
Salo Hopeless

Importar SVG como componente React

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

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

export default MyComponent ;
Captain Khaled

reaccionar SVG

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

Respuestas similares a “importar svg react”

Preguntas similares a “importar svg react”

Más respuestas relacionadas con “importar svg react” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código