-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathCommentList.js
More file actions
37 lines (33 loc) · 981 Bytes
/
CommentList.js
File metadata and controls
37 lines (33 loc) · 981 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React from 'react';
import PropTypes from 'prop-types';
// Import Components
import CommentListItem from './CommentListItem/CommentListItem';
function CommentList(props) {
return (
<div className="listView">
{props.comments.map(comment => (
<div>
<CommentListItem
comment={comment}
key={comment.cuid}
onUpdate={content => props.handleOnUpdate(comment.cuid, content)}
onEdit={() => props.handleOnEdit(comment.cuid)}
onDelete={() => props.handleDeleteComment(comment.cuid)}
/>
</div>
))}
</div>
);
}
CommentList.propTypes = {
comments: PropTypes.arrayOf(
PropTypes.shape({
author: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
slug: PropTypes.string.isRequired,
cuid: PropTypes.string.isRequired,
})
).isRequired,
handleDeleteComment: PropTypes.func.isRequired,
};
export default CommentList;