-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
add task solution #1366
base: master
Are you sure you want to change the base?
add task solution #1366
Conversation
maximka-gif
commented
Feb 17, 2025
- DEMO LINK
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.
Thank you for your hard work on this pull request! 😊 There are a couple of critical issues that need to be addressed to meet the core requirements of the task:
-
Key Prop in Iterations: The
PostList
component is missing akey
prop for thePostInfo
component within the.map
function. Adding a uniquekey
is essential for React to efficiently update and manage lists. Please use a unique identifier from thepost
object, such aspost.id
, to ensure each child in the list has a unique key. -
Naming Consistency: The property
comment
should be renamed tocomments
in both theposts
object and when passing it to theCommentList
component. This change will align with naming conventions, improve code readability, and maintain consistency.
Once these issues are resolved, your code will be in great shape! Keep up the great work, and feel free to reach out if you need any assistance. 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review
button in the Reviewers tab.
src/App.jsx
Outdated
export const posts = postsFromServer.map(post => ({ | ||
...post, | ||
user: getUserById(post.userId), | ||
comment: getCommentsById(post.id), |
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.
Consider renaming the comment
property to comments
to better reflect that it holds an array of comments. This will improve code readability and maintain consistency with naming conventions.
src/components/PostInfo/PostInfo.jsx
Outdated
</div> | ||
|
||
<p className="PostInfo__body">{post.body}</p> | ||
<CommentList comments={post.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.
The property comment
should be renamed to comments
when passing it to the CommentList
component. This change will align with the naming convention and improve code readability.
src/components/PostList/PostList.jsx
Outdated
export const PostList = ({ posts }) => ( | ||
<div className="PostList"> | ||
{posts.map(post => ( | ||
<PostInfo post={post} /> |
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.
Add a key
prop to the PostInfo
component. Use a unique identifier from the post
object, such as post.id
, to ensure each child in the list has a unique key.
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.
Review Summary
Great job on your implementation! 🎉 Your code meets the task requirements and constraints, and you've successfully addressed the previous issues:
-
Key Prop in Iterations: You've ensured that the
PostList
component correctly includes akey
prop for eachPostInfo
component usingpost.id
as a unique identifier. This is crucial for React's list rendering performance. -
Naming Consistency: The
comments
property is consistently used throughout your code, which helps maintain clarity and functionality.
While your code is approved, remember to always ensure that each component in a list has a unique key
prop to optimize React's rendering process. This will help you avoid potential issues in larger applications.
Keep up the great work, and continue to learn and improve your coding skills! If you encounter any critical issues in the future, make sure to address them promptly to enhance your code's functionality and maintainability. Happy coding! 🚀
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
</div> | ||
</div> | ||
</div> | ||
<PostList posts={posts} /> |
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.
Ensure that the PostList
component assigns a unique key
prop to each PostInfo
component within it. This is crucial for React to efficiently update and manage lists. Consider using a unique identifier from the post
object, such as post.id
, to ensure each child in the list has a unique key.