Home > OS >  image loading is not working properly in react
image loading is not working properly in react

Time:12-19

how to display image through online URL path in react ,if I try to do that code its not working

import React from 'react';
export default function Dropdown() {
return (
    <div>
    <img alt="picture"src="https://pixabay.com/photos/strawberries-fruit-season-eating-3359755/" 
    height={200} width={200}/>
    </div>
  );
}

CodePudding user response:

It' just that your source image is wrong. Try this:

import React from 'react';
export default function Dropdown() {
return (
    <div>
    <img alt="picture" src="https://cdn.pixabay.com/photo/2018/04/29/11/54/strawberries-3359755_960_720.jpg" height={200} width={200}/>
    </div>
  );
}

CodePudding user response:

Your source image link is invalid..

change to this: <img alt="picture" src="https://cdn.pixabay.com/photo/2018/04/29/11/54/strawberries-3359755_960_720.jpg" height={200} width={200}/>

  • Related