-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathPostList.js
40 lines (36 loc) · 1.02 KB
/
PostList.js
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
38
39
40
import React from 'react';
import PropTypes from 'prop-types';
// Import Components
import PostListItem from './PostListItem/PostListItem';
function PostList(props) {
return (
<div className="listView">
{
props.posts.map(post => (
<PostListItem
post={post}
key={post.cuid}
onDelete={() => props.handleDeletePost(post.cuid)}
/>
))
}
</div>
);
}
PostList.propTypes = {
posts: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
content: PropTypes.string.isRequired,
slug: PropTypes.string.isRequired,
cuid: PropTypes.string.isRequired,
comments: PropTypes.arrayOf(PropTypes.shape({
authorName: PropTypes.string.isRequired,
comment: PropTypes.string.isRequired,
postId: PropTypes.string.isRequired,
_id: PropTypes.string.isRequired,
})).isRequired,
})).isRequired,
handleDeletePost: PropTypes.func.isRequired,
};
export default PostList;