mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-22 16:46:28 +01:00
Memoize the Parent
This commit is contained in:
parent
96f6091131
commit
163961c494
1 changed files with 5 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
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 QuickPinchZoom, { make3dTransformValue } from 'react-quick-pinch-zoom';
|
||||||
|
|
||||||
import Icon from './icon';
|
import Icon from './icon';
|
||||||
|
@ -79,7 +79,10 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
||||||
onUpdate,
|
onUpdate,
|
||||||
};
|
};
|
||||||
|
|
||||||
const Parent = to ? (props) => <Link to={to} {...props} /> : 'div';
|
const Parent = useMemo(
|
||||||
|
() => (to ? (props) => <Link to={to} {...props} /> : 'div'),
|
||||||
|
[to],
|
||||||
|
);
|
||||||
|
|
||||||
if (type === 'image' || (type === 'unknown' && previewUrl && url)) {
|
if (type === 'image' || (type === 'unknown' && previewUrl && url)) {
|
||||||
// Note: type: unknown might not have width/height
|
// Note: type: unknown might not have width/height
|
||||||
|
|
Loading…
Reference in a new issue