Last active
November 17, 2018 09:03
Star
You must be signed in to star a gist
Youtube in React: make comments dynamic
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 from 'react'; | |
import {CommentsHeader} from "./CommentsHeader/CommentsHeader"; | |
import {Comment} from './Comment/Comment'; | |
import {AddComment} from './AddComment/AddComment'; | |
export class Comments extends React.Component { | |
render() { | |
if (!this.props.comments) { | |
return <div/>; | |
} | |
const comments = this.props.comments.map((comment) => { | |
return <Comment comment={comment} key={comment.id}/> | |
}); | |
return( | |
<div> | |
<CommentsHeader amountComments={this.props.amountComments}/> | |
<AddComment key='add-comment'/> | |
{comments} | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment