import React from 'react'; import { Link } from 'react-router-dom'; import CommentsContainer from '../comments/comments_container'; class NewsFeedIndexItem extends React.Component{ constructor(props){ super(props); this.handleSubmit = this.handleSubmit.bind(this); } handleSubmit(e){ this.props.deletePost(this.props.post.id) .then(()=>this.props.fetchNewsFeed()); } renderImage(){ if(this.props.post.photo.match( '/assets/missing-post')){ return null ; }else{ return (
); } } renderDelete(){ if(this.props.currentUser.id === this.props.post.author_id){ return(
this.handleSubmit()}> ...
); }else{ return null; } } render(){ const { post, deletePost,user,fetchNewsFeed} = this.props; return (
  • {post.authorfname}

    {this.renderDelete()}

    {post.body}

    {this.renderImage()}
  • ); } } export default NewsFeedIndexItem;