diff options
| author | Wes Bos <wesbos@gmail.com> | 2017-09-21 15:39:12 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2017-09-21 15:39:12 -0400 |
| commit | 3b45dd7b593825721ec9ee9f6a49c732601b1ae0 (patch) | |
| tree | a2e8e73d6b6b6bc32eda2bb79af817397e4304f5 /components/SingleItem.js | |
| parent | 1450e579c67e3d969cb099dfe6c1cefd1e313fb5 (diff) | |
Cha Ching
Diffstat (limited to 'components/SingleItem.js')
| -rw-r--r-- | components/SingleItem.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/components/SingleItem.js b/components/SingleItem.js new file mode 100644 index 0000000..297c33d --- /dev/null +++ b/components/SingleItem.js @@ -0,0 +1,36 @@ +import { graphql, compose } from 'react-apollo'; +import { Motion, spring } from 'react-motion'; +import { SINGLE_ITEM_QUERY } from '../queries'; +import makeImage from '../lib/image'; + +const SingleItem = props => { + if (!props.findItem.Item) return <p>Not ready</p>; + console.log(props.findItem.Item); + + if (props.loading) return <p>Loading...</p>; + if (props.error) return <p>Error...</p>; + + const item = props.findItem.Item; + return ( + <div> + <img src={makeImage(item.image)} alt={item.title} /> + <h2>Viewing {item.title}</h2> + + <Motion defaultStyle={{ x: 0 }} style={{ x: spring(100) }}> + {value => <div>{value.x}</div>} + </Motion> + </div> + ); +}; + +const ComponentWithMutations = compose( + graphql(SINGLE_ITEM_QUERY, { + name: 'findItem', + // This comes from Props + options: ({ id }) => ({ + variables: { id }, + }), + }) +)(SingleItem); + +export default ComponentWithMutations; |
