Skip to content

Instantly share code, notes, and snippets.

@kfarst
Created May 18, 2018 23:40
Show Gist options
  • Save kfarst/2f2504a22fcc9bf876a85462977a68e2 to your computer and use it in GitHub Desktop.
Save kfarst/2f2504a22fcc9bf876a85462977a68e2 to your computer and use it in GitHub Desktop.
import React from 'react';
import { QueryRenderer, graphql } from 'react-relay';
class Example extends React.Component {
render() {
return (
<QueryRenderer
environment={environment}
query={graphql`
query ExampleQuery($pageID: ID!) {
page(id: $pageID) {
name
}
}
`}
variables={{
pageID: '110798995619330',
}}
render={({error, props}) => {
if (error) {
return <div>{error.message}</div>;
} else if (props) {
return <div>{props.page.name} is great!</div>;
}
return <div>Loading</div>;
}}
/>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment