Skip to content

Commit 12f8095

Browse files
committed
remove useMemo
1 parent e8b9900 commit 12f8095

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/components/react/ImageBlurPreloader.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,9 @@ const ImageBlurPreloader: FC<Props> = ({
2828

2929
const prevMainAttributes = usePrevious(mainAttributes);
3030

31-
const { src, srcSet } = mainAttributes;
32-
const { src: prevSrc, srcSet: prevSrcSet } = prevMainAttributes ?? {};
33-
34-
const isNewImage = useMemo(
35-
() => !(prevSrc === src && prevSrcSet === srcSet),
36-
[src, srcSet, prevSrc, prevSrcSet]
31+
const isNewImage = !(
32+
prevMainAttributes?.src === mainAttributes.src &&
33+
prevMainAttributes.srcSet === mainAttributes.srcSet
3734
);
3835

3936
// reset isLoading on main image change
@@ -55,11 +52,14 @@ const ImageBlurPreloader: FC<Props> = ({
5552
// blur image must use size from main image
5653
width: mainAttributes.width,
5754
height: mainAttributes.height,
55+
alt: !isLoadingMain ? mainAttributes.alt : '',
5856
};
5957

60-
const hasImage = isLoadingMain
61-
? mainAttributes.src || mainAttributes.srcSet
62-
: blurAttributes.src || blurAttributes.srcSet;
58+
const hasImage = Boolean(
59+
isLoadingMain
60+
? mainAttributes.src || mainAttributes.srcSet
61+
: blurAttributes.src || blurAttributes.srcSet
62+
);
6363

6464
return (
6565
<div className={cn('relative size-full', divClassName)}>

0 commit comments

Comments
 (0)