import { useQuery } from '@apollo/client' import Item, { ItemSkeleton } from './item' import styles from './items.module.css' import { MORE_ITEMS } from '../fragments/items' import { useRouter } from 'next/router' import MoreFooter from './more-footer' export default function Items ({ variables, rank, items, cursor }) { const router = useRouter() const { data, fetchMore } = useQuery(MORE_ITEMS, { variables, fetchPolicy: router.query.cache ? 'cache-first' : undefined }) if (!data && !items) { return } if (data) { ({ moreItems: { items, cursor } } = data) } return ( <>
{items.map((item, i) => ( ))}
} /> ) } function ItemsSkeleton ({ rank, startRank = 0 }) { const items = new Array(21).fill(null) return (
{items.map((_, i) => ( ))}
) }