Skip to content

Commit f31ca6f

Browse files
committed
chore: refactor
1 parent aad0244 commit f31ca6f

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/components/UploadcareImage.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import { getInt } from '../utils/helpers';
88
import { uploadcareLoader } from '../utils/loader';
99

1010
const shouldOverrideBlurDataUrl = (props: ImageProps): boolean => {
11-
return props.placeholder === 'blur' && !props.blurDataURL;
11+
return (
12+
typeof props.src === 'string' &&
13+
props.placeholder === 'blur' &&
14+
!props.blurDataURL
15+
);
1216
};
1317

1418
const generateBlurDataUrl = (
@@ -27,15 +31,11 @@ const generateBlurDataUrl = (
2731
};
2832

2933
export function UploadcareImage(props: ImageProps): JSX.Element {
30-
let blurDataURL: string | undefined;
31-
if (typeof props.src === 'string' && shouldOverrideBlurDataUrl(props)) {
32-
blurDataURL = generateBlurDataUrl(props.src, props.width);
34+
let blurDataURL = props.blurDataURL;
35+
if (shouldOverrideBlurDataUrl(props)) {
36+
blurDataURL = generateBlurDataUrl(props.src as string, props.width);
3337
}
3438
return (
35-
<Image
36-
loader={uploadcareLoader}
37-
blurDataURL={blurDataURL ?? props.blurDataURL}
38-
{...props}
39-
/>
39+
<Image loader={uploadcareLoader} blurDataURL={blurDataURL} {...props} />
4040
);
4141
}

0 commit comments

Comments
 (0)