Created
May 18, 2018 23:40
-
-
Save kfarst/2f2504a22fcc9bf876a85462977a68e2 to your computer and use it in GitHub Desktop.
This file contains 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 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