Check fallback fade/image load status on mount

This commit is contained in:
Sam Becker 2025-07-16 17:35:09 -05:00
parent f2db4cf4d0
commit 2dde902027

View File

@ -33,16 +33,12 @@ export default function ImageWithFallback({
const onError = useCallback(() => setDidError(true), []);
useEffect(() => {
const timeout = setTimeout(() => {
// If image is still loading after 50ms, force CSS animation
if (
!ref.current?.complete ||
(ref.current?.naturalWidth ?? 0) === 0
) {
setFadeFallbackTransition(true);
}
}, 50);
return () => clearTimeout(timeout);
if (
!ref.current?.complete ||
(ref.current?.naturalWidth ?? 0) === 0
) {
setFadeFallbackTransition(true);
}
}, []);
const getBlurClass = () => {