stream-saga/src/js/components/Posts.jsx

34 lines
655 B
React
Raw Normal View History

2019-06-19 17:08:53 -04:00
import React, { Component } from "react"
import { connect } from "react-redux"
import { getData } from "../actions/index"
export class Post extends Component {
componentDidMount() {
this.props.getData()
}
render() {
return (
<ul className="list-group list-group-flush">
{this.props.articles.map(el => (
2019-06-21 00:06:42 -04:00
<li className="list-group-item" key={el.id_str}>
<p>{el.created_at}</p>
<p>{el.text}</p>
2019-06-19 17:08:53 -04:00
</li>
))}
</ul>
)
}
}
function mapStateToProps(state) {
return {
articles: state.remoteArticles.slice(0, 10)
}
}
export default connect(
mapStateToProps,
{ getData }
)(Post)