File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
apps/kyb-app/src/components/layouts/AppShell Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1+ import { useRefValue } from '@/hooks/useRefValue' ;
12import { useEffect } from 'react' ;
23
34interface Props {
@@ -16,14 +17,16 @@ const prefetchImage = (url: string) =>
1617const fallback = ( timeout : number ) => new Promise ( resolve => setTimeout ( resolve , timeout ) ) ;
1718
1819export const Logo = ( { logoSrc, appName, onLoad } : Props ) => {
20+ const onLoadRef = useRefValue ( onLoad ) ;
21+
1922 useEffect ( ( ) => {
2023 if ( ! onLoad ) {
2124 return ;
2225 }
2326
2427 // Using race here in case if image is corrupted or load takes to long we don't want to lock stepper breadcrumbs forever.
25- Promise . race ( [ prefetchImage ( logoSrc ) , fallback ( 3000 ) ] ) . then ( onLoad ) ;
26- } , [ logoSrc , onLoad ] ) ;
28+ Promise . race ( [ prefetchImage ( logoSrc ) , fallback ( 3000 ) ] ) . then ( onLoadRef . current ) ;
29+ } , [ logoSrc , onLoadRef ] ) ;
2730
2831 return < img src = { logoSrc } alt = { appName } className = "max-h-[80px] max-w-[200px] object-cover" /> ;
2932} ;
You can’t perform that action at this time.
0 commit comments