Last active
April 1, 2017 20:42
-
-
Save ColeTownsend/b3412e71eb8ed117e60ed48d6e4d05f4 to your computer and use it in GitHub Desktop.
The Post component
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, { PropTypes } from 'react'; | |
import moment from 'moment'; | |
export default class Post extends React.Component { | |
constructor (props) { | |
super(props); | |
} | |
render () { | |
const { | |
id, | |
description, | |
name, | |
thumbnails, | |
link, | |
created_at, | |
} = this.props.post; | |
const collectionId = this.props.post.collection_id; | |
return ( | |
<div | |
key={id} | |
> | |
<div> | |
<img alt={name} src={thumbnails.large} /> | |
</div> | |
<div> | |
<div> | |
{link | |
? <a href={link}> | |
<h3>{name}</h3> | |
</a> | |
: <h3>{name}</h3> | |
} | |
</div> | |
<h5>Added {moment(created_at).fromNow()}</h5> | |
{description && | |
<div> | |
<p>{description}</p> | |
</div> | |
} | |
</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment