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 LoadingItem from './LoadingItem'; 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, }; render() { return (
{({ data, error, loading }) => { if (loading) { return ( {Array.from({ length: 4 }) .map((x, id) => ({ id })) .map(x => )} ); } if (error) return
Error
; return {data.items.map(item => )}; }}
); } } export default ItemList;