Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
以下の4点を修正
・if の条件を修正
・即時関数の return が欠けているので追加
・Post の prop title が重複しているので修正
・Post に key 追加
  • Loading branch information
jun68ykt committed Aug 24, 2019
1 parent ccfd346 commit 4dcfbb4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/containers/Index.js
Expand Up @@ -29,16 +29,26 @@ class Index extends Component {
return(
<div>
{(() => {
if (this.state.posts != []) {
this.state.posts.map( post => {
return(
<Post title={post.created_at} name='testUser' title={post.title} content={post.content} />
)
})
if (this.state.posts.length > 0) {
return (
this.state.posts.map( (post, i) => {
return(
<Post
key={i}
createdAt={post.created_at}
name='testUser'
title={post.title}
content={post.content}
/>
)
})
)
} else {
<Typography variant="h1" component="h2">
まだなにも投稿されていません。
</Typography>
return (
<Typography variant="h1" component="h2">
まだなにも投稿されていません。
</Typography>
)
}
})()}
</div>
Expand Down

0 comments on commit 4dcfbb4

Please sign in to comment.