Dark Knight
Dark Knight

Reputation: 1093

Property 'onload' does not exist on type <ImgHTMLAttributes>

There is my code to use image tag in typescript

<img
  className="mediaImg"
  src={imageUrl}
  onload={() => console.log('dffffffffffffffffffffffff')}
  style={{ ...theme.messages.mediaImg }}
/>

When I use onload attribute there I get the error

Property 'onload' does not exist on type 'DetailedHTMLProps<ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>'

Any help would be appreciated!!! Thank you

Upvotes: 0

Views: 2459

Answers (1)

Amruth
Amruth

Reputation: 5912

You have to call onLoad instead onload.

<img
 className="mediaImg"
 src={imageUrl}
 onLoad={() => console.log('dffffffffffffffffffffffff')}
 style={{ ...theme.messages.mediaImg }}
/>

Upvotes: 2

Related Questions