Created
June 13, 2019 16:19
-
-
Save kayode-adechinan/eab8dbbfcacde9e1485f0c220868019b 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
function Blog(props) { | |
const sidebar = ( | |
<ul> | |
{props.posts.map((post) => | |
<li key={post.id}> | |
{post.title} | |
</li> | |
)} | |
</ul> | |
); | |
const content = props.posts.map((post) => | |
<div key={post.id}> | |
<h3>{post.title}</h3> | |
<p>{post.content}</p> | |
</div> | |
); | |
return ( | |
<div> | |
{sidebar} | |
<hr /> | |
{content} | |
</div> | |
); | |
} | |
const posts = [ | |
{id: 1, title: 'Hello World', content: 'Welcome to learning React!'}, | |
{id: 2, title: 'Installation', content: 'You can install React from npm.'} | |
]; | |
ReactDOM.render( | |
<Blog posts={posts} />, | |
document.getElementById('root') | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment