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

apply bind to onload #11

Closed
wants to merge 1 commit into from
Closed

apply bind to onload #11

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Apr 3, 2020

No description provided.

@lavrton
Copy link
Member

lavrton commented Apr 3, 2020

Why do we need it?

@ghost
Copy link
Author

ghost commented Apr 3, 2020

When I made production build of my code, I was getting img as undefined inside the onload function because of the binding issue (took me a whole day to find that). It was a very weird issue, cause it code was working well on the development environment.

@lavrton
Copy link
Member

lavrton commented Apr 3, 2020

Interesting. I don't see how image can be undefined here. Can you copy minified version of use-image lib from production build?

@ghost
Copy link
Author

ghost commented Apr 3, 2020

Sure, I will copy that.

@ghost
Copy link
Author

ghost commented Apr 3, 2020

This is what I have got:

function(U,c,t){var e=t(0),a={image:void 0,status:" loading "};U.exports=function(U,c){var t=e.useState(a),f=t[0].image,d=t[0].status,b=t[1];return e.useEffect(function(){function t(){b({image:f,status:" loaded "})}function e(){b({image:void 0,status:" failed "})}if(U){const f=document.createElement(" img ");return f.addEventListener(" load ",t),f.addEventListener(" error ",e),c&&(f.crossOrigin=c),f.src=U,function(){f.removeEventListener(" load ",t),f.removeEventListener(" error ",e),b(a)}}},[U,c]),[f,d]}},function(U,c,t){var e=t(887);" string "===typeof e&&(e=[[U.i,e," "]]);var a={};a.transform=void 0;t(135)(e,a);e.locals&&(U.exports=e.locals)}

@lavrton
Copy link
Member

lavrton commented Apr 6, 2020

What tools are you using for making a production build? That looks like a bug in the minifier.

@lavrton
Copy link
Member

lavrton commented Jun 18, 2020

The last version should fix the issue.

@lavrton lavrton closed this Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants