import { Component } from 'react' import { withApollo, graphql, compose } from 'react-apollo' import UpdateItem from './UpdateItem'; import Link from 'next/link'; import styled from 'styled-components'; import TakeMyMoney from './TakeMyMoney'; import AddToCart from './AddToCart'; import Pagination from './Pagination'; import formatMoney from '../lib/formatMoney'; import makeImage from '../lib/image'; import slugify from 'slugify'; import { ALL_ITEMS_QUERY, DELETE_ITEM_MUTATION } from '../queries'; const Title = styled.h1` font-size: 10px; `; const Items = styled.div` display: grid; grid-template-columns: repeat(4, calc(33% - 20px)); grid-gap: 20px; `; const Item = styled.div` background: #f3f3f3; padding: 5px; img { width: 100%; } `; class ItemList extends Component { componentDidMount() { this.prefetchNextItems(this.props.page); } componentWillReceiveProps(nextProps) { // update the next items if the page prop changed if(this.props.page !== nextProps.page) { this.prefetchNextItems(nextProps.page); } } prefetchNextItems = (currentPage) => { const page = currentPage + 1; console.log(`Prefetching Next items! Page ${page}`); this.props.client.query({ query: ALL_ITEMS_QUERY, variables: { skip: (page * 3) - 3 } }) } render() { console.log("CLIENTTT!!", this.props.client); // 1 if (this.props.allItemsQuery && this.props.allItemsQuery.loading) { return
{item.description}
Edit ✏️