From ca8a149b3992746114afee684e848dc5ff876e12 Mon Sep 17 00:00:00 2001 From: ventura Date: Thu, 21 Mar 2024 12:28:52 -0700 Subject: [PATCH] resolve flicker --- src/components/Image/BaseImage.native.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/Image/BaseImage.native.tsx b/src/components/Image/BaseImage.native.tsx index 3be1933af50c..3f692d0d95cf 100644 --- a/src/components/Image/BaseImage.native.tsx +++ b/src/components/Image/BaseImage.native.tsx @@ -1,17 +1,22 @@ import {Image as ExpoImage} from 'expo-image'; import type {ImageLoadEventData} from 'expo-image'; -import {useCallback} from 'react'; +import {useCallback, useRef} from 'react'; import type {BaseImageProps} from './types'; function BaseImage({onLoad, ...props}: BaseImageProps) { + const isLoadedRef = useRef(false); const imageLoadedSuccessfully = useCallback( (event: ImageLoadEventData) => { if (!onLoad) { return; } + if (isLoadedRef.current === true) { + return; + } // We override `onLoad`, so both web and native have the same signature const {width, height} = event.source; + isLoadedRef.current = true; onLoad({nativeEvent: {width, height}}); }, [onLoad],