Created
July 16, 2018 12:49
-
-
Save jackyef/a7821241b663c5191f67da126fee4e06 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
// we can destructure Fetch's state here | |
renderContent = ({ data, error, loading, errorMessage }) => { | |
const { id } = this.props; | |
if (error) { | |
return <p>an error happened while trying to fetch comic #{id}</p>; | |
} | |
if (loading) { | |
return <p>loading...</p>; | |
} | |
if (data) { | |
const { alt, img, title } = data; | |
return ( | |
<Fragment> | |
<h3>{title}</h3> | |
<figure> | |
<a href={img} target="_blank" rel="noreferrer nofollow noopener"><img src={img} /></a> | |
<figcaption>{alt}</figcaption> | |
</figure> | |
</Fragment> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment