Fix state-tracking
This commit is contained in:
parent
7181a75bfb
commit
568ff92582
1 changed files with 10 additions and 2 deletions
|
@ -48,15 +48,23 @@ export function AutoSizedImage({
|
|||
}, [imgInfo, containerInfo])
|
||||
|
||||
useEffect(() => {
|
||||
let aborted = false
|
||||
Image.getSize(
|
||||
uri,
|
||||
(width: number, height: number) => {
|
||||
setImgInfo({width, height})
|
||||
if (!aborted) {
|
||||
setImgInfo({width, height})
|
||||
}
|
||||
},
|
||||
(error: any) => {
|
||||
setError(String(error))
|
||||
if (!aborted) {
|
||||
setError(String(error))
|
||||
}
|
||||
},
|
||||
)
|
||||
return () => {
|
||||
aborted = true
|
||||
}
|
||||
}, [uri])
|
||||
|
||||
const onLayout = (evt: LayoutChangeEvent) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue