mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-24 16:58:47 +01:00
Test memoize Media
This commit is contained in:
parent
2a91c005a1
commit
57d6889826
1 changed files with 12 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
import { getBlurHashAverageColor } from 'fast-blurhash';
|
import { getBlurHashAverageColor } from 'fast-blurhash';
|
||||||
import { Fragment } from 'preact';
|
import { Fragment } from 'preact';
|
||||||
|
import { memo } from 'preact/compat';
|
||||||
import {
|
import {
|
||||||
useCallback,
|
useCallback,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
|
@ -676,4 +677,14 @@ function getURLObj(url) {
|
||||||
return URL.parse(url, location.origin);
|
return URL.parse(url, location.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Media;
|
export default memo(Media, (oldProps, newProps) => {
|
||||||
|
const oldMedia = oldProps.media || {};
|
||||||
|
const newMedia = newProps.media || {};
|
||||||
|
|
||||||
|
return (
|
||||||
|
oldMedia?.id === newMedia?.id &&
|
||||||
|
oldMedia.url === newMedia.url &&
|
||||||
|
oldProps.to === newProps.to &&
|
||||||
|
oldProps.class === newProps.class
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in a new issue