Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.