Last active
March 26, 2018 15:34
-
-
Save gc-codesnippets/12a66f07ee735f21831f37be21d0ad40 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
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