blob: d4bec4fa90f7cdf0927421006421e3f0e582bbbb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
import { Query } from 'react-apollo';
import PropTypes from 'prop-types';
import { SINGLE_ITEM_QUERY } from '../queries/index';
const SingleItem = props => (
<Query query={SINGLE_ITEM_QUERY} variables={{ id: props.id }}>
{({ data: { items }, loading, error }) => {
if (loading || error) return null;
const [item] = items;
return (
<div>
<img src={item.largeImage || item.image} alt={item.title} />
<h2>Viewing {item.title}</h2>
<p>{item.description}</p>
</div>
);
}}
</Query>
);
SingleItem.propTypes = {
id: PropTypes.string.isRequired,
};
export default SingleItem;
|