import React from 'react'; import { Query } from 'react-apollo'; import styled from 'styled-components'; import PropTypes from 'prop-types'; import Pagination from './Pagination'; import Item from './Item'; import { perPage } from '../config'; import { ALL_ITEMS_QUERY } from '../queries/queries'; const Items = styled.div` display: grid; grid-template-columns: 1fr 1fr; grid-gap: 60px; max-width: ${props => props.theme.maxWidth}; margin: 0 auto; `; const Center = styled.div` text-align: center; `; class ItemList extends React.Component { static propTypes = { page: PropTypes.number.isRequired, }; static getDerivedStateFromProps(nextProps, state) { return { refetch: state.page !== nextProps.page }; } state = { refetch: false, }; render() { const fetchPolicy = this.state.refetch ? 'network-only' : 'cache-first'; return (