Last active
August 6, 2019 10:55
-
-
Save hwillson/80629aa1d0a3fcfd6a6c61149c74c80e to your computer and use it in GitHub Desktop.
React Apollo 3 - useQuery
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
const LAST_LAUNCH = gql` | |
query lastLaunch { | |
launch { | |
id | |
timestamp | |
} | |
} | |
`; | |
export function LastLaunch() { | |
const { loading, data } = useQuery(LAST_LAUNCH); | |
return ( | |
<div> | |
<h1>Last Launch</h1> | |
{loading ? <p>Loading</p> : <p>Timestamp: {data.launch.timestamp}</p>} | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment