Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react image

<img src={require('./logo.jpeg')} />

import logo from './logo.jpeg'; // with import    
const logo = require('./logo.jpeg); // with require
<img src={logo} />
Comment

img src in react js

import Logo from “./logo.png”;
<img src={Logo}/>
Comment

img tag in react

//two way to use image in react
Option 1: Put the image in the public directory
public/images/thing.jpg, you could display that image this way:
   <img src="images/logo.jpg" />

Option 2: import the image into the component
import Logo from “./logo.jpg”;
<img src={Logo}/>
Comment

image react

First method 
import logo from './logo.jpeg';    <img src={logo} />
Second Method
const logo = require('./logo.jpeg); <img src={logo.default} />
Third Method
<img src={require('./logo.jpeg').default} />
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular dynamic class 
Javascript :: jquery get all text inputs 
Javascript :: Vue use props in style 
Javascript :: copy to clipboard js 
Javascript :: javascript get first property of object 
Javascript :: add image in react native 
Javascript :: nuxt-link name params 
Javascript :: localstorage 
Javascript :: jquery format date 
Javascript :: javascript convert number to string with 2 decimal places 
Javascript :: how get first option in select in vue js 
Javascript :: hello word in js 
Javascript :: clear input field jquery 
Javascript :: js sort numbers descending order 
Javascript :: giving an html element own attribute using js 
Javascript :: target url javascript 
Javascript :: desable no unused vars in vue.js 
Javascript :: Getting Elements by Class Name 
Javascript :: react-router 
Javascript :: ajax failure response 
Javascript :: count number of divs inside a div javascript 
Javascript :: convert date online in moment js 
Javascript :: wordpress load latest jQuery 
Javascript :: mocha should throw error 
Javascript :: run a code after delay js 
Javascript :: how to find lcm in javascript 
Javascript :: array reverse algorithm in js 
Javascript :: unload in jquery 
Javascript :: calculato 
Javascript :: mil to km javascript 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =