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

Undefined is not an object (evaluating 'this.props.preview') [Android] #10

Closed
alanlanglois opened this issue Feb 1, 2018 · 9 comments
Closed

Comments

@alanlanglois
Copy link

image

Thanks for your awesome lib, it works pretty well!

However I get this error sometimes. I'm testing my app super fast, it might be related.
My guess is that the component is maybe removed before download is finished.

I'll dig a little more and let you know if I find something.

Cheers,

@alanlanglois
Copy link
Author

Adding this in Image.js line 51 seems to do the job :

if(this.props == undefined ) return;

alanlanglois added a commit to alanlanglois/react-native-expo-image-cache that referenced this issue Feb 1, 2018
Maybe it causes some side effects, I haven't digged so much in your code :)
@alanlanglois
Copy link
Author

It does not really fix it. At least I don't get the redscreen anymore, but now the pictures is not displayed with a full opacity.
I'm suspecting the animation to causes bugs, maybe we should cancel/stop it when receiving componentWillUnmount()?

@alanlanglois alanlanglois changed the title Undefined is not an object (evaluating 'this.props.preview') Undefined is not an object (evaluating 'this.props.preview') (on Android) Feb 1, 2018
@alanlanglois alanlanglois changed the title Undefined is not an object (evaluating 'this.props.preview') (on Android) Undefined is not an object (evaluating 'this.props.preview') [Android] Feb 1, 2018
@wcandillon
Copy link
Owner

@alanlanglois Thank you so much! I never had the error myself but some user have reported it. Do you think it can be the animation? I guess it wouldn't hurt to do more clean up on unmount(). It could be also onLoadEnd() called when the component is unmounted.

@alanlanglois
Copy link
Author

@wcandillon : Thanks for the fast reply :)
I'm kind of new in the whole React Native world, but my guess is that the onLoadEnd is called when the component is unmounted (that would explain why this.props is undefined) AND/OR that the animation is completed while the component is already unmounted (or being unmounted)

@wcandillon
Copy link
Owner

@alanlanglois You are 100% correct, I'll try to push a fix for it asap.

@alanlanglois
Copy link
Author

@wcandillon Looking the RN doc, it seems like there is no way to cancel an Image loading in the RN Image component... that would have been very convenient :)
I'd say adding a variable isMounted could be a quick fix to implement.

Sounds like we are not alone!

@wcandillon
Copy link
Owner

Woah thank you so much for your support on that issue!

@wcandillon
Copy link
Owner

Feel free to re-open is needed :)

@alanlanglois
Copy link
Author

@wcandillon it's fixed!

But'ill maybe open a new one though :)

I got the picture loaded, but sometimes (and it's kind of random), the picture won't appear fully oppacified, if I go back wait a little a try again it will eventually work as expected... or not, until it works again, and doesn't again.
Can't reproduce on iOS, it seems to be Android specific.
I'll try to find why and how to explain.

Thanks for the fix!

Cheers,

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

No branches or pull requests

2 participants