Skip to content

Commit

Permalink
三項演算子を使用
Browse files Browse the repository at this point in the history
  • Loading branch information
jun68ykt committed Aug 24, 2019
1 parent 4dcfbb4 commit 9d469d9
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/containers/Index.js
Expand Up @@ -28,29 +28,23 @@ class Index extends Component {
render(){
return(
<div>
{(() => {
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}
/>
)
})
{this.state.posts.length > 0 ? (
this.state.posts.map( (post, i) =>
<Post
key={i}
createdAt={post.created_at}
name='testUser'
title={post.title}
content={post.content}
/>
)
} else {
return (
<Typography variant="h1" component="h2">
まだなにも投稿されていません。
</Typography>
)
}
})()}
)
: (
<Typography variant="h1" component="h2">
まだなにも投稿されていません。
</Typography>
)
}
</div>
);
}
Expand Down

0 comments on commit 9d469d9

Please sign in to comment.