Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onLoad, onError, onLoadStart and onLoadEnd do not fire for Image. #18502

Closed
3 tasks done
ingvardm opened this issue Mar 22, 2018 · 12 comments
Closed
3 tasks done

onLoad, onError, onLoadStart and onLoadEnd do not fire for Image. #18502

ingvardm opened this issue Mar 22, 2018 · 12 comments
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@ingvardm
Copy link

ingvardm commented Mar 22, 2018

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

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.54?

Thank you for your contributions.

@ingvardm
Copy link
Author

updated react-native and description

@hramos hramos removed the Platform: macOS Building on macOS. label Mar 29, 2018
@namnh240795
Copy link

Same problems on android. 7.1.1
React Version: 16.3.0 alpha 1
React-Native Version: 54.0

Image error uri: http://media.hottab.net/uploads/api.hottabpos.com/206/thumbs/HeaderLogo_5bajVUqT.png

@MohamedHamedTHL

This comment has been minimized.

@iMerica
Copy link

iMerica commented Jun 6, 2018

Issue persists using latest and greatest as of today

@bkkwok
Copy link

bkkwok commented Jun 7, 2018

Anyone know what version of React-Native these event handlers worked? Specifically onError.

onLoad, onLoadStart and onLoadEnd work on v55.4 for both ios and android for me. But onError does not. I need to provide a placeholder image when the Image fails to load correctly.

@duhseekoh
Copy link

None of the loading or error handlers on v55.4 work for me...

@ayehia
Copy link

ayehia commented Aug 14, 2018

The same issue here :(

@luisbraganca
Copy link

luisbraganca commented Aug 28, 2018

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):

constructor(props) {
    super(props);
    this.state = { loaded: false };
}

_finishLoading = function () {
    console.log("Finished loading");
    this.setState({ loaded: true });
}

render = function () {
    return <Image onLoadEnd={this._finishLoading.bind(this)} {...this.props} />;
}

However, this code below does not work at all (it's a non-working LazyImage implementation):

constructor(props) {
    super(props);
    this.state = { loaded: false };
}

_finishLoading = function () {
    console.log("Finished loading");
    this.setState({ loaded: true });
}

render = function () {
    var image = <Image onLoadEnd={this._finishLoading.bind(this)} {...this.props} />;
    return this.state.loaded ? image : <Image {...this.props} source={Loader} />;
}

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 the this.state.loading to true

@FibreFoX
Copy link

onError seens to not being used on Android, other issues already existing for this:
#19073
#7440

Can't speak for the other events :(

@stale
Copy link

stale bot commented Nov 27, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 27, 2018
@stale
Copy link

stale bot commented Dec 4, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Dec 4, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Dec 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests