Task solution#2021
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Great job on implementing the task! 🎉 The code is well-structured and meets most of the requirements. There are a couple of minor improvements you could make, such as avoiding unnecessary React fragments and renaming the getUser function to getUserById for clarity. Keep up the good work and happy coding! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
| import { User } from './components/Types/Users'; | ||
| import { PostList } from './components/PostList'; | ||
|
|
||
| function getUser(userId: number): User { |
There was a problem hiding this comment.
The function getUser should be renamed to getUserById to clearly indicate that it retrieves a user by their ID. This aligns with the checklist item: "If you are searching some entity by some filter, specify it in function/method name".
| <> | ||
| <hr /> | ||
|
|
||
| <b data-cy="NoCommentsMessage">No comments yet</b> | ||
| </> |
There was a problem hiding this comment.
Avoid using a React fragment (<>...</>) when there is already a wrapper element present, such as the <div> with the class CommentList. This aligns with the checklist item: "Don't use React fragment, if you already have a wrapper".
| <> | ||
| <div className="PostInfo"> | ||
| <div className="PostInfo__header"> | ||
| <h3 className="PostInfo__title">{post.title}</h3> | ||
| <p> | ||
| {' Posted by '} | ||
| <UserInfo user={post.user} /> | ||
| </p> | ||
| </div> | ||
| <p className="PostInfo__body">{post.body}</p> | ||
| <CommentList comments={post.comments} /> | ||
| </div> | ||
| </> |
There was a problem hiding this comment.
Avoid using a React fragment (<>...</>) when there is already a wrapper element present, such as the <div> with the class PostInfo. This aligns with the checklist item: "Don't use React fragment, if you already have a wrapper".
| <> | ||
| {posts.map(post => ( | ||
| <PostInfo key={post.id} post={post} /> | ||
| ))} | ||
| </> |
There was a problem hiding this comment.
Avoid using a React fragment (<>...</>) when there is already a wrapper element present, such as the <div> with the class PostList. This aligns with the checklist item: "Don't use React fragment, if you already have a wrapper" .
[DEMO LINK] (https://MateuszCieplak.github.io/react_static-list-of-posts/)