|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import React from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import store from '../store.js';
|
|
|
|
|
|
|
|
|
|
|
|
class CommentsList extends React.Component {
|
|
|
|
class CommentsList extends React.Component {
|
|
|
|
render(){
|
|
|
|
render(){
|
|
|
|
@ -10,6 +11,16 @@ class CommentsList extends React.Component {
|
|
|
|
</ul>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount(){
|
|
|
|
|
|
|
|
fetch('https://stupidcomments.herokuapp.com/comments').then(function(response){
|
|
|
|
|
|
|
|
response.json().then(function(data){
|
|
|
|
|
|
|
|
let commentsArray = data.map(function(comment){
|
|
|
|
|
|
|
|
return comment.body
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
store.dispatch({type:'SET', comments:commentsArray});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = function(state){
|
|
|
|
const mapStateToProps = function(state){
|
|
|
|
|