import LinkCard from "@/components/LinkViews/LinkCard"; import { useLinks } from "@/hooks/store/links"; import { LinkIncludingShortenedCollectionAndTags } from "@/types/global"; import { useEffect } from "react"; import { useInView } from "react-intersection-observer"; import { GridLoader } from "react-spinners"; export default function CardView({ links, editMode, isLoading, }: { links: LinkIncludingShortenedCollectionAndTags[]; editMode?: boolean; isLoading?: boolean; }) { const { ref, inView } = useInView(); const { data } = useLinks(); useEffect(() => { if (inView) { data.fetchNextPage(); } }, [data.fetchNextPage, inView]); return (
{links.map((e, i) => { return ( ); })} {data.hasNextPage && (
)} {isLoading && links.length > 0 && ( )}
); }