unmounting fix

This commit is contained in:
feruz 2021-01-18 13:54:38 +02:00
parent 6066c58d43
commit 70e82e2042

View File

@ -41,11 +41,17 @@ const PostListItemView = ({
const [calcImgHeight, setCalcImgHeight] = useState(300);
// Component Life Cycles
useEffect(() => {
let _isMounted = false;
if (image) {
ImageSize.getSize(image.uri).then((size) => {
setCalcImgHeight((size.height / size.width) * dim.width);
});
if (!_isMounted) {
ImageSize.getSize(image.uri).then((size) => {
setCalcImgHeight((size.height / size.width) * dim.width);
});
}
}
return () => {
_isMounted = true;
};
}, []);
// Component Functions