File size: 990 Bytes
f5071ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
import React from 'react';
import PostIndexItem from './post_index_item';
import CreatePostFormContainer from './create_post_form_container';
class PostIndex extends React.Component {
constructor(props){
super(props);
}
componentDidMount() {
this.props.fetchAllPosts();
}
render() {
const posts = this.props.posts.reverse().map(post => {
if(post.wall_id === this.props.user.id){
return (
<PostIndexItem
key={post.id}
post= {post}
user={this.props.user}
deletePost={this.props.deletePost}
fetchAllPosts={this.props.fetchAllPosts}
currentUser={this.props.currentUser}
users={this.props.users}/>
);
}else{
return null;
}
});
return (
<div>
<CreatePostFormContainer user={this.props.user}
currentUser={this.props.currentUser}/>
<ul>
{posts}
</ul>
</div>
);
}
}
export default PostIndex;
|