react import default image from assets code example
Example 1: React import image with url
import React from "react";
import ReactDOM from "react-dom";
function App() {
return (
<img
src="https://images.pexels.com/photos/20787/pexels-photo.jpg?auto=compress&cs=tinysrgb&h=350"
alt="new"
/>
);
}
const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);
Example 2: import img react in another file
import lostImage from './assets/img/illustrations/lost.svg';
export { lostImage };
import {lostImage} from './images.js'