Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #869

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Solution #869

wants to merge 5 commits into from

Conversation

FocusHuK
Copy link

No description provided.

src/App.tsx Outdated
const copy = {
...post,
user: users.find(user => user.id === post.userId) || null,
comment: comments.find(comment => comment.postId === post.userId) || null,

Choose a reason for hiding this comment

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

Комментариев может быть больше 1, используй filter

border-left: 10px solid blue;
font-size: 20px;
letter-spacing: 2px;
transition: 0.3s all linear;

Choose a reason for hiding this comment

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

Указывай какое именно свойство меняется, не используй all

import './CommentList.scss';

type Props = {
all: Comment,

Choose a reason for hiding this comment

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

all странное название для переменной, comments подойдет лучше

Comment on lines 24 to 25
{user ? (<UserInfo {...user} />) : ('no user')}
{comment ? (<CommentList all={comment} />) : ('no comment')}

Choose a reason for hiding this comment

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

Suggested change
{user ? (<UserInfo {...user} />) : ('no user')}
{comment ? (<CommentList all={comment} />) : ('no comment')}
{user && <UserInfo {...user} />}
{comment && <CommentList all={comment} />}

@@ -0,0 +1,17 @@
[data-cy="post-info"] {

Choose a reason for hiding this comment

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

Почему ты стилизуешь через data атрибуты, а не через классы?

@FocusHuK
Copy link
Author

Я все ошибки по исправлял, но не понял про комментарий.

const copy = {
...post,
user: users.find(user => user.id === post.userId) || null,
comment: comments.find(comment => comment.postId === post.userId) || null,
}
т.е. объект может иметь у одного пользователя много комментариев в таком формате?
const copy = {
...post,
user: {},
comment: {},
comment1: {},
comment2: {},
}
или как?

@vkryvytskyy
Copy link

Я все ошибки по исправлял, но не понял про комментарий.

const copy = { ...post, user: users.find(user => user.id === post.userId) || null, comment: comments.find(comment => comment.postId === post.userId) || null, } т.е. объект может иметь у одного пользователя много комментариев в таком формате? const copy = { ...post, user: {}, comment: {}, comment1: {}, comment2: {}, } или как?

Он может иметь много комментариев в таком формате:

const post = {
  comments: [{ comment }, { comment }, ...]
}

title: string,
body: string,
user: User | null,
comment: Comment | null;

Choose a reason for hiding this comment

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

Suggested change
comment: Comment | null;
comments: Comment[] | null;

src/App.tsx Outdated
@@ -12,7 +12,7 @@ const preparedPosts: Post[] = posts.map((post) => {
const copy = {
...post,
user: users.find(user => user.id === post.userId) || null,
comment: comments.find(comment => comment.postId === post.userId) || null,
comment: comments.filter(comment => comment.postId === post.id) || null,

Choose a reason for hiding this comment

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

Suggested change
comment: comments.filter(comment => comment.postId === post.id) || null,
comments: comments.filter(comment => comment.postId === post.id) || null,

@@ -8,7 +8,7 @@ type Props = {
title: string,
body: string,
user: User | null,
comment: Comment | null;
comment: Comment[] | null;

Choose a reason for hiding this comment

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

Suggested change
comment: Comment[] | null;
comments: Comment[] | null;

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.

None yet

2 participants