Fix state-tracking

zio/stable
Paul Frazee 2022-12-14 15:49:45 -06:00
parent 7181a75bfb
commit 568ff92582
1 changed files with 10 additions and 2 deletions

View File

@ -48,15 +48,23 @@ export function AutoSizedImage({
}, [imgInfo, containerInfo]) }, [imgInfo, containerInfo])
useEffect(() => { useEffect(() => {
let aborted = false
Image.getSize( Image.getSize(
uri, uri,
(width: number, height: number) => { (width: number, height: number) => {
setImgInfo({width, height}) if (!aborted) {
setImgInfo({width, height})
}
}, },
(error: any) => { (error: any) => {
setError(String(error)) if (!aborted) {
setError(String(error))
}
}, },
) )
return () => {
aborted = true
}
}, [uri]) }, [uri])
const onLayout = (evt: LayoutChangeEvent) => { const onLayout = (evt: LayoutChangeEvent) => {