Skip to content

Commit

Permalink
shows a blog post
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Jan 25, 2016
1 parent d6d298a commit 678e572
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions blog/src/components/posts_show.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,24 @@ class PostsShow extends Component {
}

render() {
return <div>Show post {this.props.params.id}</div>;
const { post } = this.props;

if (!post) {
return <div>Loading...</div>;
}

return (
<div>
<h3>{post.title}</h3>
<h6>Categories: {post.categories}</h6>
<p>{post.content}</p>
</div>
);
}
}

export default connect(null, { fetchPost })(PostsShow);
function mapStateToProps(state) {
return { post: state.posts.post };
}

export default connect(mapStateToProps, { fetchPost })(PostsShow);

0 comments on commit 678e572

Please sign in to comment.