File tree 3 files changed +38
-4
lines changed
3 files changed +38
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import "../styles/app.css" ;
3
- import Post from "./Post " ;
3
+ import PostList from "./Postlist " ;
4
4
5
5
import placeholderData from "../data/posts.json"
6
6
@@ -11,12 +11,10 @@ const App = () => {
11
11
< div className = "app__foreground-wrap" >
12
12
< div className = "app__title" > Intro to React II</ div >
13
13
{
14
- // TODO: Send data to Post component and verify it works
15
- // wrap all Posts in a PostList component
16
14
// TODO: Create a Postlist component to wrap all Posts in,
17
15
// display name of last upvoted post at the top
18
16
}
19
- < Post postData = { placeholderData [ 0 ] } />
17
+ < PostList posts = { placeholderData } />
20
18
</ div >
21
19
</ div >
22
20
) ;
Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import PropTypes from "prop-types" ;
3
+
4
+ import "../styles/postlist.css"
5
+
6
+ import Post from "./Post" ;
7
+
8
+ const PostList = ( { posts } ) => {
9
+ return (
10
+ < div className = "postlist" >
11
+ { posts . map ( ( post ) => (
12
+ < Post key = { post . id } postData = { post } />
13
+ ) ) }
14
+ </ div >
15
+ ) ;
16
+ } ;
17
+
18
+ PostList . propTypes = {
19
+ posts : PropTypes . arrayOf (
20
+ PropTypes . shape ( {
21
+ author : PropTypes . string ,
22
+ body : PropTypes . string ,
23
+ date : PropTypes . string ,
24
+ isPublished : PropTypes . bool ,
25
+ tags : PropTypes . arrayOf ( PropTypes . string ) ,
26
+ title : PropTypes . string ,
27
+ } )
28
+ ) . isRequired ,
29
+ } ;
30
+
31
+ export default PostList ;
Original file line number Diff line number Diff line change
1
+ .postlist {
2
+ padding-left : 24px ;
3
+ padding-right : 24px ;
4
+ padding-bottom : 24px ;
5
+ }
You can’t perform that action at this time.
0 commit comments