mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-16 15:21:48 +03: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 { Fragment } from 'preact';
|
||||
import { memo } from 'preact/compat';
|
||||
import {
|
||||
useCallback,
|
||||
useLayoutEffect,
|
||||
|
@ -676,4 +677,14 @@ function getURLObj(url) {
|
|||
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…
Add table
Reference in a new issue