question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bug: onLoadStart is not passed to img

See original GitHub issue

Although 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

  1. With Firefox open browser development tools
  2. Disable browser’s cache
  3. Using Firefox go to https://ukpcn.csb.app/
  4. 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:open
  • Created 3 years ago
  • Reactions:6
  • Comments:6

github_iconTop GitHub Comments

3reactions
keulcommented, Nov 11, 2021

My understanding of the issues:

I’m not sure why React should handle this differently from what the browser is doing.

1reaction
sami616commented, Nov 11, 2021

This seems like something that will need to be fixed for triggering suspense boundaries for images using the loading='lazy' attribute.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found