Bug: onLoadStart is not passed to img
See original GitHub issueAlthough it seem a valid event, and it works using vanilla HTML/JS (at least Firefox, Chrome still have an open bug https://bugs.chromium.org/p/chromium/issues/detail?id=458851), it seems that using and onLoadStart
event on an img
is not working in react.
React version: 17.0.0
Steps To Reproduce
- With Firefox open browser development tools
- Disable browser’s cache
- Using Firefox go to https://ukpcn.csb.app/
- Check the console
Link to code example: https://codesandbox.io/s/onloadstart-issue-ukpcn
The current behavior
The console shown:
Vanilla img loading
Vanilla img loaded
React img loaded
Seems that the onLoadStart
is not working.
The expected behavior
The onLoadStart
function should be executed, so logging also React img loading
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6
Top Results From Across the Web
loadstart event is not fired when <img> resource starts loading.
1. Create an HTML file with an <img> image. 2. Bind the loadstart event to the element and do something. 3. The event...
Read more >React onLoad event on image tag is not getting called when ...
When image is not loaded you aren't actually rendering the image. You need to render it for its onLoad to fire
Read more >Re: Issue 7731 in chromium: Image onload event does not fire ...
Re: Issue 7731 in chromium: Image onload event does not fire when loading an already loaded image.
Read more >onloadstart Event - W3Schools
onloadstart Event ... The onloadstart event occurs when the browser starts the loading process of an ... onerror, An error occurs while loading...
Read more >FileReader: loadstart event - Web APIs | MDN
This event is not cancelable and does not bubble. ... <img src="" class="preview" height="200" alt="Image preview" ... dfn-onloadstart ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My understanding of the issues:
onloadstart
event is valid event for images in the specs: https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onloadstartI’m not sure why React should handle this differently from what the browser is doing.
This seems like something that will need to be fixed for triggering suspense boundaries for images using the
loading='lazy'
attribute.