Answers for "react import local image"

12

import img react

//if you have images in src folder
import shoe1 from './img/shoe_01.jpg'
const Shoe = (e) => {
	return ( 
        <div className="shoe-container">
            <img src={shoe1} alt=""/>
        </div>
    );
}
//if you have images in public folder:
//will look in folder /public/img/shoe_01.jpg
const Shoe = (e) => {
	return ( 
        <div className="shoe-container">
            <img src="/img/shoe_01.jpg" alt=""/>
        </div>
    );
}
Posted by: Guest on September-09-2020
3

react js image path src from local folder

// Assuming logo.png is in the same folder as JS file
import logo from './logo.png';

// ...later
<img src={logo} alt="logo" />
Posted by: Guest on September-11-2020
1

react import local image

// Assuming logo.png is in the same folder as JS file
import logo from './logo.png';

// ...later
<img src={logo} alt="logo" />
Posted by: Guest on August-03-2021
4

import img react in another file

//import imgs in a different js file
import lostImage from './assets/img/illustrations/lost.svg';
export { lostImage }; 

//import in the component to use it
import {lostImage} from './images.js'
Posted by: Guest on September-13-2020

Code answers related to "react import local image"

Code answers related to "Javascript"

Browse Popular Code Answers by Language