Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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 :: javascript arrays 
Javascript :: react update version 
Javascript :: export default module 
Javascript :: how to add a class in classlist and remove after 100 ms using jquery 
Javascript :: javascript link to google maps route 
Javascript :: supertest formdata 
Javascript :: How to validate an unicode email address in JavaScript 
Javascript :: only allow requests from domain express 
Javascript :: e editable select no button 
Javascript :: ease between 2 points 
Javascript :: regular expression email 
Javascript :: delay sleep 
Javascript :: js get target foreach 
Javascript :: using while loop to create table rows js 
Javascript :: define dynamic initial values for Formik in React 
Javascript :: How to write on a web page javascript 
Javascript :: js array entries 
Javascript :: how to hide a screen from drawer in react navigation 5 
Javascript :: Getting Search Parameters From A URL As An Array 
Javascript :: how to log bodyparser error 
Javascript :: remove all white spaces and different characters globally 
Javascript :: react axios fetchData with loading screen plus API 
Javascript :: sharepoint javascript get current user 
Javascript :: geolocation 
Javascript :: javascript null Conversion to Number 
Javascript :: dart how to convert json to x-www-form-urlencoded 
Javascript :: const { something} javascript 
Javascript :: loop through elements by name js 
Javascript :: onclick timer javascript 
Javascript :: js remove trailling lines 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =