Skip to content

Commit

Permalink
fix: avoid crashing image if null
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaelbr committed Dec 18, 2024
1 parent 2760dfc commit 7f60d86
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/components/image/SanityImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ const useNextSanityGlobalImage = (
useState<UseNextSanityImageProps | null>(null);

useEffect(() => {
fetch(studioImage.src).then((r) => r.ok && setGlobalImage(studioImage));
fetch(sharedImage.src).then((r) => r.ok && setGlobalImage(sharedImage));
if (studioImage) {
fetch(studioImage.src).then((r) => r.ok && setGlobalImage(studioImage));
}
if (sharedImage) {
fetch(sharedImage.src).then((r) => r.ok && setGlobalImage(sharedImage));
}
}, [studioImage, sharedImage]);

return globalImage;
Expand Down

0 comments on commit 7f60d86

Please sign in to comment.