Created
September 15, 2021 00:46
-
-
Save natafaye/b49ad38f1113daa7399321b26202fa40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import PostList from './components/PostList' | |
export default class App extends Component { | |
render() { | |
return ( | |
<div> | |
This text is in App.js | |
<PostList/> | |
</div> | |
) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
export default class Post extends Component { | |
render() { | |
const post = { | |
text: "This is a hard coded post", | |
author: "Natalie" | |
} | |
return ( | |
<div> | |
<h2>{ post.author }</h2> | |
<p>{ post.text }</p> | |
<button>Comment</button> | |
</div> | |
) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react' | |
import Post from './Post' | |
export default class PostList extends Component { | |
render() { | |
const posts = [ | |
{ | |
text: "1 post", | |
author: "Natalie" | |
}, | |
{ | |
text: "2 post", | |
author: "Linda" | |
}, | |
{ | |
text: "3 post", | |
author: "Jennifer" | |
}, | |
{ | |
text: "4 post", | |
author: "Natalie" | |
}, | |
] | |
// We're making a post for each post we have in the list, but we're not actually telling our Post component | |
// which post it should be displaying. We'll need props for that! | |
return ( | |
<div> | |
{ posts.map(post => <Post/> ) } | |
</div> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment