SteffeyDev / react-native-popover-view

A well-tested, adaptable, lightweight <Popover> component for react-native
MIT License
614 stars 92 forks source link

Fix android crash issue when component unmount #64

Closed MengWeiChen closed 4 years ago

MengWeiChen commented 4 years ago

Fix android crash issue when component unmount before animation is finished

SteffeyDev commented 4 years ago

Thanks for raising this issue. I saw your fix, but opted for a different fix that hopefully accomplishes the same thing without adding another class variable (e865fd8). Thanks for contributing regardless, I always appreciate the community support! I released 2.1.2 with the fix, let me know if it also solves your crash.

MengWeiChen commented 4 years ago

Sorry, I don't explain clearly enough before.

Actually, the crash reason is not caused by animateOut, My case is when Popover is mounted, animateIn is playing, then user unmount the Popover component. Now Popover is unmounted, but the animation (animateIn) is not complete. When the animation is complete, it will trigger getRectForRef, but popoverRef does not exist anymore. Finally, popoverRef gets nothing, that causes crash happen.

So do you have any other idea to fix this issue?

thanks.

SteffeyDev commented 4 years ago

Ok, I published 2.1.3 with a second fix, that is similar to yours but with an additional check to make sure this.popoverRef is not null. See if that works for you. Thanks for explaining, I hadn't considered that situation.

MengWeiChen commented 4 years ago

Version 2.1.3 fix my crash issue very well 😀.

SteffeyDev commented 4 years ago

Ok great to hear! Thanks again for your help.