https://camjackson.net/post/9-things-every-reactjs-beginner-should-know
Created
July 31, 2016 14:38
-
-
Save nishinoshake/ebf2d32439bbc8013a8058ef36251ee3 to your computer and use it in GitHub Desktop.
シンプルなReactコンポーネントのループ
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
const LatestPostsComponent = props => { | |
const postPreviews = renderPostPreviews(props.posts); | |
return ( | |
<section> | |
<div><h1>Latest posts</h1></div> | |
<div> | |
{ postPreviews } | |
</div> | |
</section> | |
); | |
}; | |
const renderPostPreviews = posts => ( | |
posts.map(post => this.renderPostPreview(post)) | |
); | |
const renderPostPreview = post => ( | |
<article> | |
<h3><a href={`/post/${post.slug}`}>{post.title}</a></h3> | |
<time pubdate><em>{post.posted}</em></time> | |
<div> | |
<span>{post.blurb}</span> | |
<a href={`/post/${post.slug}`}>Read more...</a> | |
</div> | |
</article> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment