1
0
Fork 0
This repository has been archived on 2022-09-24. You can view files and clone it, but cannot push or open issues or pull requests.
sudoscientist-js-frontend/src/components/Post.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-05-29 14:01:40 +00:00
import React from 'react';
import ReactMarkdown from 'react-markdown';
import { connect } from 'react-redux';
import { fetchPosts } from '../actions';
class Post extends React.Component {
componentDidMount() {
this.props.fetchPost();
}
renderList() {
return this.props.posts.map(post => {
return (
<div className="item" key={post.id}>
<div className="content">
<div className="description">
<h1>{post.title}</h1>
<ReactMarkdown source={post.content} />
</div>
</div>
</div>
);
});
}
render () {
console.log(this.props.posts)
return (
<div className="ui relaxed divided list">
{this.renderList()}
</div>
);
}
}
const mapStateToProps = (state) => {
return { posts: state.posts };
}
export default connect(
mapStateToProps,
{ fetchPosts }
)(Post);