I am displaying an image on React web app.
My code is like below:
<img
alt={fileName}
onLoad={onLoad}
src={url}
/>
I want to display an indicator around the image, which tells user about the image download percentage.
I know with onLoad
property is to provide a function which will be called when image finishes loading, but I don't know how to detect the image downloading percentage (or downloaded size).
Is there a property like onLoad
? I tried onProgress
but it didn't get fired.
I've read this question JavaScript loading progress of an image.
But the highest vote answer in this question doesn't answer my question.
That answer needs to create a new Image() instance manually, what I want is to know whether there is a built-in support for onProgress
property, or please advise how to build a lower mechanism to support this.