diff --git a/src/components/media.jsx b/src/components/media.jsx index 0b32e053..cac624c0 100644 --- a/src/components/media.jsx +++ b/src/components/media.jsx @@ -1,5 +1,5 @@ import { getBlurHashAverageColor } from 'fast-blurhash'; -import { useCallback, useRef, useState } from 'preact/hooks'; +import { useCallback, useMemo, useRef, useState } from 'preact/hooks'; import QuickPinchZoom, { make3dTransformValue } from 'react-quick-pinch-zoom'; import Icon from './icon'; @@ -79,7 +79,10 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) { onUpdate, }; - const Parent = to ? (props) => : 'div'; + const Parent = useMemo( + () => (to ? (props) => : 'div'), + [to], + ); if (type === 'image' || (type === 'unknown' && previewUrl && url)) { // Note: type: unknown might not have width/height