Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

importing svg into react

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

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

import svg react

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

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

how to import svg in 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;
Comment

import svg as react component

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

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

export default MyComponent ;
Comment

Svg as a component react

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

const App = () => {
  return (
    <div className="App">
      <ReactLogo />
    </div>
  );
}
export default App;
Comment

how to add svg file in react

import YourSvg from "/path/to/image.svg";

const App = () => {
  return (
    <div className="App">
      <img src={YourSvg} alt="Your SVG" />
    </div>
  );
};
export default App;
Comment

add svg in react

<span>
                  <object style={{ float: 'left', height: '15px', position: 'relative', top: '4px' }} data={`${ROOT_URL}/assets/images/svg-icons/history-icon.svg`} type='image/svg+xml'></object>
                </span>
Comment

convert svg to react component

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

string to svg react

import SVG from 'react-inlinesvg';

...    

const mySVG = '<svg xmlns="http://www.w3.org/2000/svg">...</svg>';
return <SVG src={mySVG} />;
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery prev 
Javascript :: lodash uniqby 
Javascript :: How to use `setState` callback on react hooks 
Javascript :: autocomplete data selected validation jquery 
Javascript :: datatable sAjaxSource get output 
Javascript :: jsfuck 
Javascript :: hash_hmac javascript 
Javascript :: javascript audio navigator audio stream 
Javascript :: image downloader extension in nodejs 
Javascript :: appinsights trackException javascript 
Javascript :: if in javascript 
Javascript :: delay / sleep program in js 
Javascript :: play audio file in phaser 
Javascript :: crear etiquetas html con javascript 
Javascript :: nunjucks check if in array 
Javascript :: valueof js 
Javascript :: fs readfile encoding 
Javascript :: order by type 
Javascript :: Yan Nesting For Loops 
Javascript :: ask for expo token and save to firebase 
Javascript :: react disabled attribute 
Javascript :: check if localstorage is undefined 
Javascript :: separador de miles javascript 
Javascript :: mongoose sort 
Javascript :: javascript this Inside Constructor Function 
Javascript :: jquery how to get element insde div 
Javascript :: destructuring object 
Javascript :: leaflet flyto 
Javascript :: add pdf in react app 
Javascript :: threejs heart 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =