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

39 lines
979 B
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';
2019-06-22 22:08:02 +00:00
import { fetchPost } from '../actions';
2019-07-23 23:12:48 +00:00
import { Link } from 'react-router-dom';
2019-05-29 14:01:40 +00:00
class Post extends React.Component {
componentDidMount() {
2019-07-23 23:12:48 +00:00
const { slug } = this.props.match.params
this.props.fetchPost(slug);
2019-05-29 14:01:40 +00:00
}
render () {
2019-07-24 00:39:53 +00:00
console.log(this.props.posts)
return (
<div className="item" key="{post.id}">
<div className="content">
<div className="description">
<h1><b><u><Link to={"/posts/"}>""</Link></u></b></h1>
<ReactMarkdown source="{post.content}" />
</div>
</div>
</div>
);
2019-05-29 14:01:40 +00:00
}
}
const mapStateToProps = (state) => {
2019-07-23 23:12:48 +00:00
return {
posts: state.posts,
slug: state.slug
};
2019-05-29 14:01:40 +00:00
}
export default connect(
mapStateToProps,
2019-07-23 23:12:48 +00:00
{ fetchPost }
2019-05-29 14:01:40 +00:00
)(Post);