Skip to content

Instantly share code, notes, and snippets.

@larkintuckerllc
Created June 2, 2018 14:49
Show Gist options
  • Save larkintuckerllc/de22f0ad818558233a212868cd09561d to your computer and use it in GitHub Desktop.
Save larkintuckerllc/de22f0ad818558233a212868cd09561d to your computer and use it in GitHub Desktop.
GraphQL and Apollo Client by Example: Part 2 - 2
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