Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

svg component react js

import { ReactComponent as IconMenu } from './icons/menu.svg'

<IconMenu />
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

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

react svg

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

PREVIOUS NEXT
Code Example
Javascript :: print object keys 
Javascript :: dynamic calendar in javascript with example 
Javascript :: JS two numbers in array whose sum equals a given number 
Javascript :: axios check 401 run function 
Javascript :: comparing two arrays in javascript 
Javascript :: removeeventlistener click 
Javascript :: javascript copy content of one div to another 
Javascript :: momentjs display timezone 
Javascript :: jquery input hidden value 
Javascript :: get keys length jquery 
Javascript :: JavaScript string encryption and decryption 
Javascript :: request entity too large express 
Javascript :: add 2 for hours in date timestamp js 
Javascript :: get zipcode from google places autocomplete 
Javascript :: par ou impar js 
Javascript :: jquery add option if not exist 
Javascript :: javascript unselect radio 
Javascript :: 2nd highest number from array 
Javascript :: js sort 
Javascript :: hide the js code from source 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: react JSON data to display in a table 
Javascript :: how to change the first 3 letters from a string toupper case 
Javascript :: regex.match 
Javascript :: using ejs with express 
Javascript :: Validate email or phone number javascript 
Javascript :: express cors specific origins 
Javascript :: math.max in javascript 
Javascript :: javascript image to variable 
Javascript :: ran ctrl c and npm server is still running 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =