Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

showing an image in react js

import image from './path-to-image';

<img src={image} height={100} width={100} />
Comment

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

how to display image in react js component

// METHOD 1
import logo from './logo.jpeg';
<img src={logo} />
  
// Method 2
const logo = require('./logo.jpeg'); 
<img src={logo.default} />
  
// Method 3
<img src={require('./logo.jpeg').default} />
Comment

image view component react js

import { PhotoProvider, PhotoView } from 'react-photo-view';
import 'react-photo-view/dist/react-photo-view.css';

export default function App() {
  return (
    <PhotoProvider>
      <PhotoView src="/1.jpg">
        <img src="/1-thumbnail.jpg" alt="" />
      </PhotoView>
    </PhotoProvider>
  );
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: adding js file to reactjs 
Javascript :: javascript if value is a string function 
Javascript :: how to add youtube videos to react app 
Javascript :: javascript calculator 
Javascript :: vue 3 cdn example 
Javascript :: javascript object array contains 
Javascript :: install vue js 
Javascript :: chartjs each dataset get colors 
Javascript :: tolocalestring format dd-mm-yyyy 
Javascript :: Easy REACT download image 
Javascript :: how to use uniqid 
Javascript :: nextjs global scss variables 
Javascript :: array js fill 
Javascript :: async import javascript 
Javascript :: get element of an array inside another array 
Javascript :: optional chaining javascript 
Javascript :: tribonacci sequence javascript 
Javascript :: get first duv with jquery 
Javascript :: select react hook form yup validation 
Javascript :: download images from http link in react 
Javascript :: format date javascript 
Javascript :: Sorting an array of objects by property values 
Javascript :: mongodb data types 
Javascript :: how to convert set to a string in js 
Javascript :: javascript code to calculate compound interest 
Javascript :: png to base64 javascript 
Javascript :: js loader 
Javascript :: sort arrays according to first array js 
Javascript :: Iteration over JS object 
Javascript :: chunk an array 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =