Skip to content

PavelKlenin_lesson7#63

Open
PavelKlenin wants to merge 6 commits into
LeonEsquire:masterfrom
PavelKlenin:master
Open

PavelKlenin_lesson7#63
PavelKlenin wants to merge 6 commits into
LeonEsquire:masterfrom
PavelKlenin:master

Conversation

@PavelKlenin

Copy link
Copy Markdown
Contributor

No description provided.

author: state.postCard.author,
})

export default connect(mapStatetoProps)(PostCard); No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class PostCard extends React.Component {

    componentDidMount () {
        const postID = this.props.params.postID;
        this.props.dispatch(fetchPostCard(postID));
    }

    render () {
        let postCard = 'loading...';
        if (this.props.post.id === +this.props.params.postID)
        {
            const comments = this.props.comments.map((comment, index) => {
                return (
                    <Comment key={index} {...comment}/>
                );
            })

            postCard = (
                <div>
                    <Post {...this.props.post} author ={this.props.author}/>
                    <hr/>
                    <h3>Comments</h3>
                    <hr/>
                    {comments}
                </div>
            );
        }
        return postCard;
    }
}

export default PostList; No newline at end of file
const mapStateToProps = (state) => ({posts: state.posts.posts,})

export default connect(mapStateToProps)(PostList); No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class PostList extends React.Component {
    render () {

        let posts = 'Loading...';
        if (this.props.fetched) {
            posts = this.props.posts.map((post, index) => {
                return (
                    <Post key={index} {...post}/>
                );
            });
        }

        return (
            <div>
                <h1>Blogs</h1>
                {posts}
            </div>
        );    
    }

    componentDidMount () {
        this.props.dispatch(fetchPosts());
    }
}

const mapStateToProps = (state) => ({
    posts: state.posts.posts,
    fetched: state.posts.fetched
})

@PavelKlenin

Copy link
Copy Markdown
Contributor Author

Спасибо, исправил

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants