From d6ebb8690baad5cfca7bfc68119e6c4ac104d60b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Mon, 25 Mar 2024 11:06:38 +0100 Subject: [PATCH] Review --- src/components/utils/Image.tsx | 6 +++++- src/components/utils/ZoomImage.tsx | 5 ++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/utils/Image.tsx b/src/components/utils/Image.tsx index 2021d1648..6fad1371b 100644 --- a/src/components/utils/Image.tsx +++ b/src/components/utils/Image.tsx @@ -87,6 +87,10 @@ interface ImageCommonProps { inlineStyle?: React.CSSProperties; } +interface ImgDOMPropsWithSrc extends React.ComponentPropsWithoutRef<'img'> { + src: string; +} + /** * Render an image that will be swapped depending on the theme. * We don't use the `next/image` component because we need to load images from external sources, @@ -271,7 +275,7 @@ async function ImagePicture( }); } - const imgProps: React.ComponentPropsWithoutRef<'img'> & { src: string } = { + const imgProps: ImgDOMPropsWithSrc = { alt, style, loading, diff --git a/src/components/utils/ZoomImage.tsx b/src/components/utils/ZoomImage.tsx index 4302d0c1f..4999bdeef 100644 --- a/src/components/utils/ZoomImage.tsx +++ b/src/components/utils/ZoomImage.tsx @@ -28,7 +28,6 @@ export function ZoomImage( // Only allow zooming when image will not actually be larger and on mobile React.useEffect(() => { if (isTouchDevice()) { - setZoomable(false); return; } @@ -70,7 +69,7 @@ export function ZoomImage( resizeObserver?.disconnect(); mediaQueryList.removeEventListener('change', onChange); }; - }, [imgRef, width, setZoomable]); + }, [imgRef, width]); // Preload the image that will be displayed in the modal if (zoomable) { @@ -100,7 +99,7 @@ export function ZoomImage( setActive(false); }, ); - }, [setOpened]); + }, []); return ( <>