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
base: master
Are you sure you want to change the base?
Solution #869
Conversation
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Комментариев может быть больше 1, используй filter
src/components/CommentList.scss
Outdated
border-left: 10px solid blue; | ||
font-size: 20px; | ||
letter-spacing: 2px; | ||
transition: 0.3s all linear; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Указывай какое именно свойство меняется, не используй all
src/components/CommentList.tsx
Outdated
import './CommentList.scss'; | ||
|
||
type Props = { | ||
all: Comment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all
странное название для переменной, comments
подойдет лучше
src/components/PostInfo.tsx
Outdated
{user ? (<UserInfo {...user} />) : ('no user')} | ||
{comment ? (<CommentList all={comment} />) : ('no comment')} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{user ? (<UserInfo {...user} />) : ('no user')} | |
{comment ? (<CommentList all={comment} />) : ('no comment')} | |
{user && <UserInfo {...user} />} | |
{comment && <CommentList all={comment} />} |
src/components/PostList.scss
Outdated
@@ -0,0 +1,17 @@ | |||
[data-cy="post-info"] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему ты стилизуешь через data атрибуты, а не через классы?
Я все ошибки по исправлял, но не понял про комментарий. const copy = { |
Он может иметь много комментариев в таком формате: const post = {
comments: [{ comment }, { comment }, ...]
} |
src/components/PostInfo.tsx
Outdated
title: string, | ||
body: string, | ||
user: User | null, | ||
comment: Comment | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment: comments.filter(comment => comment.postId === post.id) || null, | |
comments: comments.filter(comment => comment.postId === post.id) || null, |
src/components/PostInfo.tsx
Outdated
@@ -8,7 +8,7 @@ type Props = { | |||
title: string, | |||
body: string, | |||
user: User | null, | |||
comment: Comment | null; | |||
comment: Comment[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment: Comment[] | null; | |
comments: Comment[] | null; |
No description provided.