memoize imagegriditem

This commit is contained in:
Martti Malmi
2024-01-10 18:48:36 +02:00
parent 1278867ad0
commit 53488a9c59
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
import { NostrLink, TaggedNostrEvent } from "@snort/system";
import { MouseEvent, ReactNode } from "react";
import {memo, MouseEvent, ReactNode} from "react";
import { useInView } from "react-intersection-observer";
import { Link } from "react-router-dom";
@ -13,9 +13,9 @@ export interface ImageGridItemProps {
waitUntilInView?: boolean;
}
const ImageGridItem = (props: ImageGridItemProps) => {
function ImageGridItem(props: ImageGridItemProps) {
const { event, onClick } = props;
const { ref, inView } = useInView({ triggerOnce: true, rootMargin: "2000px" });
const { ref, inView } = useInView({ triggerOnce: true, rootMargin: "0px 0px 3000px 0px" });
const media = getEventMedia(event);
@ -56,4 +56,4 @@ const ImageGridItem = (props: ImageGridItemProps) => {
);
};
export default ImageGridItem;
export default memo(ImageGridItem);