Skip to content

Instantly share code, notes, and snippets.

@jbaxleyiii
Last active January 29, 2018 14:32
Show Gist options
  • Save jbaxleyiii/e2170031f9637b5314f8f896b58b6ae2 to your computer and use it in GitHub Desktop.
Save jbaxleyiii/e2170031f9637b5314f8f896b58b6ae2 to your computer and use it in GitHub Desktop.
import gql from 'graphql-tag';
import { Query } from 'react-apollo';
const query = gql`
query SomeQuery {
foo {
bar
baz
}
}
`;
function MyComponent() {
return (
<Query query={query}>
{(result) => {
if (result.loading) return <Loading />;
if (result.error) return <Error error={error} />;
const { data } = result;
return <h1>Hello {data.foo.bar} {data.foo.baz}!</h1>;
})
</Query>
);
}
@gaboe
Copy link

gaboe commented Jan 27, 2018

There is a small bug, there should be a curly bracket instead of parenthesis.

... return <h1>Hello {data.foo.bar} {data.foo.baz}!</h1>; }} </Query>

Anyway, good job with render props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment