Created
June 2, 2018 14:49
-
-
Save larkintuckerllc/de22f0ad818558233a212868cd09561d to your computer and use it in GitHub Desktop.
GraphQL and Apollo Client by Example: Part 2 - 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import gql from 'graphql-tag'; | |
| import { PropTypes } from 'prop-types'; | |
| import React from 'react'; | |
| import { Query } from 'react-apollo'; | |
| const CounterView = ({ counter }) => ( | |
| <div>{counter}</div> | |
| ); | |
| CounterView.propTypes = { | |
| counter: PropTypes.number.isRequired, | |
| }; | |
| const GET_COUNTER = gql` | |
| { | |
| counter @client | |
| } | |
| `; | |
| const Counter = () => ( | |
| <Query query={GET_COUNTER}> | |
| {({ data }) => <CounterView {...data} />} | |
| </Query> | |
| ); | |
| export default Counter; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment