-
Notifications
You must be signed in to change notification settings - Fork 110
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
Fix passing onLoad
overwrites, and call onLoad
inside onImageLoad
#120
Conversation
- Fix onLoad getting overwritten by props which cause `onImageLoad()` to never get called. - preserve the functionality of `onLoad` by adding a callback.
Thanks for your contribution, @johnsonsu! I agree that it would be a good idea to pass the event object. However, it's not clear to me whether we need to introduce a new prop for this. Could we simply use |
Hi @Aljullu, hope you are doing well! Yes, that will work for my use case. I can update my code to include the event in the return e => {
this.props.afterLoad(e);
... However, I think it's still a good idea to preserve the |
Good points, @johnsonsu. I'm thinking we should maybe simply rename the |
I think that make sense. I will update the code and docs and push it to this PR in a bit. |
@Aljullu This is ready for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, thanks again for working on this. I left one comment inline with a suggestion. Also, you will need to add onLoad
to the propTypes
and defaultProps
of that file.
Besides that, it might be a good idea to duplicate this test with the onLoad
prop.
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
I think that's a good suggestion. I've updated the code and labelled |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, this is looking good, @johnsonsu! Thanks a lot for your contribution! 🙌
Issue: Currently, there is no way to retrieve the
onLoad
event object with this library and passing anonLoad
prop toLazyLoadImage
will overwrite the handler on line 47 ofLazyLoadImage.jsx
causingafterLoad
to never get called.Description
This PR fixes passing
onLoad
toLazyLoadImage
causingafterLoad()
to never fire:onLoad
getting overwritten by props which causesonImageLoad()
to never get called.onLoad
by adding a callback.