onLoad, onError, onLoadStart and onLoadEnd do not fire for Image.
See original GitHub issue- I have reviewed the documentation
- I have searched existing issues
- I am using the latest React Native version
Environment
Environment:
OS: macOS High Sierra 10.13.3
Node: 8.9.4
Yarn: 1.5.1
npm: 5.5.1
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003
Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.54.0 => 0.54.0
Steps to Reproduce
<Image
sourse={{uri: this.props.uri}}
onLoad={this.onLoad}
onError={this.onError}
/>
Expected Behavior
Should work as described in documentation documentation
Actual Behavior
onLoad, onError, onLoadStart and onLoadEnd do not fire for Image, on both IOS and Android platforms
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:12
Top Results From Across the Web
onLoadEnd is not fired in react-native Image - Stack Overflow
returns the Image component, onLoadStart is triggered and this.state.loading is set to true . When the second render happens, this.state.loading ...
Read more >Resource loading: onload and onerror
So when we add <img> to the page, the user does not see the picture immediately. The browser needs to load it first....
Read more >Chapter 2. Making CORS requests - CORS in Action
Fires if the client aborts the request by calling the abort method. If onabort fires, the onload and onerror event handlers will not...
Read more >ASP.NET Core Blazor event handling - Microsoft Learn
Learn about Blazor's event handling features, including event argument types, event callbacks, and managing default browser events.
Read more >Cross-Site Scripting (XSS) Cheat Sheet | Web Security Academy
Event handlers that do not require user interaction ... <audio src/onerror=alert(1)> ... <image src=validimage.png onloadstart=alert(1)>.
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
Issue persists using latest and greatest as of today
It does work, it just depends on the implementation.
For example, this code below works, it fires the
console.log
(this code is not useful or anything, I just created it so I could test if the events were properly being fired):However, this code below does not work at all (it’s a non-working LazyImage implementation):
I’m assuming it’s not firing the event because the
Image
has not been mounted so it will never initiate the loading. Is there any way to force its mount or to fake mount an element? I just want it to start loading so it can change thethis.state.loading
totrue