Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active November 17, 2018 09:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save productioncoder/66ba9ae95780d8ee68ab3e8cf5a6cd14 to your computer and use it in GitHub Desktop.
Youtube in React: make comments dynamic
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