Skip to content

Instantly share code, notes, and snippets.

@hrumhrumble
Created September 26, 2017 09:33
Show Gist options
  • Save hrumhrumble/26d13927d1f0c21b031fe14114ee576d to your computer and use it in GitHub Desktop.
Save hrumhrumble/26d13927d1f0c21b031fe14114ee576d to your computer and use it in GitHub Desktop.
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import CommentList from './CommentList'
class Article extends Component {
render() {
const {article, isOpen, onButtonClick} = this.props
const body = isOpen && <section>{article.text}</section>
return (
<div>
<h2>
{article.title}
<button onClick={onButtonClick}>
{isOpen ? 'close' : 'open'}
</button>
</h2>
{body}
<h3>creation date: {(new Date(article.date)).toDateString()}</h3>
<CommentList comments={article.comments}/>
</div>
)
}
}
export default Article
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment