@@ -7,7 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
77import AttachmentOfflineIndicator from './AttachmentOfflineIndicator' ;
88import FullscreenLoadingIndicator from './FullscreenLoadingIndicator' ;
99import Image from './Image' ;
10- import type { ImageObjectPosition , ImageProps } from './Image/types' ;
10+ import type { ImageObjectPosition , ImageOnLoadEvent , ImageProps } from './Image/types' ;
1111
1212type ImageWithSizeLoadingProps = {
1313 /** Any additional styles to apply */
@@ -31,6 +31,7 @@ function ImageWithSizeCalculation({
3131 waitForSession,
3232 loadingIndicatorStyles,
3333 resizeMode,
34+ onLoad,
3435 ...rest
3536} : ImageWithSizeLoadingProps ) {
3637 const styles = useThemeStyles ( ) ;
@@ -51,10 +52,11 @@ function ImageWithSizeCalculation({
5152 setIsLoading ( false ) ;
5253 } ;
5354
54- const imageLoadedSuccessfully = ( ) => {
55+ const imageLoadedSuccessfully = ( e : ImageOnLoadEvent ) => {
5556 isLoadedRef . current = true ;
5657 setIsLoading ( false ) ;
5758 setIsImageCached ( true ) ;
59+ onLoad ?.( e ) ;
5860 } ;
5961
6062 /** Delay the loader to detect whether the image is being loaded from the cache or the internet. */
@@ -84,7 +86,9 @@ function ImageWithSizeCalculation({
8486 setIsLoading ( true ) ;
8587 } }
8688 onError = { handleError }
87- onLoad = { imageLoadedSuccessfully }
89+ onLoad = { ( e ) => {
90+ imageLoadedSuccessfully ( e ) ;
91+ } }
8892 waitForSession = { ( ) => {
8993 // Called when the image should wait for a valid session to reload
9094 // At the moment this function is called, the image is not in cache anymore
0 commit comments