Skip to content

Instantly share code, notes, and snippets.

@gc-codesnippets
Last active March 26, 2018 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gc-codesnippets/12a66f07ee735f21831f37be21d0ad40 to your computer and use it in GitHub Desktop.
Save gc-codesnippets/12a66f07ee735f21831f37be21d0ad40 to your computer and use it in GitHub Desktop.
render() {
return (
<Query query={POST_QUERY} variables={{ id: this.props.match.params.id }}>
{({ data, loading, error }) => {
if (loading) {
return (
<div className="flex w-100 h-100 items-center justify-center pt7">
<div>Loading ...</div>
</div>
)
}
if (error) {
return (
<div className="flex w-100 h-100 items-center justify-center pt7">
<div>An unexpected error occured.</div>
</div>
)
}
const { post } = data
const action = this._renderAction(post)
return (
<Fragment>
<h1 className="f3 black-80 fw4 lh-solid">{data.post.title}</h1>
<p className="black-80 fw3">{data.post.text}</p>
{action}
</Fragment>
)
}}
</Query>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment