-
-
Save hrumhrumble/26d13927d1f0c21b031fe14114ee576d 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
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