-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #1176
base: master
Are you sure you want to change the base?
Solution #1176
Conversation
RostyslavSharuiev
commented
Oct 11, 2024
- 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.
Great job on implementing the components and API utility functions! 🎉 While there are some minor syntax errors and suggestions for improved error handling, they don't critically impact the functionality. Keep up the good work and consider addressing these points in future updates for even better code quality!
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
useEffect(() => { | ||
if (!selectedUser) { | ||
return; | ||
} | ||
|
||
setIsLoading(true); | ||
setIsError(false); | ||
setUserPosts([]); | ||
setSelectedPost(null); | ||
|
||
getPosts(selectedUser.id) | ||
.then(setUserPosts) | ||
.catch(() => setIsError(true)) | ||
.finally(() => setIsLoading(false)); | ||
}, [selectedUser]); |
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.
Similar to the previous useEffect, using a try-catch block for error handling is recommended. This aligns with the checklist's suggestion to use try-catch for error handling.
) => { | ||
const { name, value } = event.target; | ||
|
||
setFormData(prevData => ({ ...prevData, [name]: value.trimStart() })); |
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.
There is a syntax error in this line. It seems like you intended to spread prevData
, but the correct syntax is { ...prevData, [name]: value.trimStart() }
. The same issue is present in line 70 with prevState
.
|
||
addComment({ | ||
postId, | ||
...trimmedData, |
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.
There is a syntax error here. You should use the spread operator correctly: { ...trimmedData }
instead of .trimmedData
.
...trimmedData, | ||
}) | ||
.then(comment => { | ||
updateComments(prevComments => [...prevComments, 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.
There is a syntax error in this line. It seems like you intended to spread prevComments
, but the correct syntax is [...prevComments, comment]
.
}) | ||
.then(comment => { | ||
updateComments(prevComments => [...prevComments, comment]); | ||
setFormData(prevState => ({ ...prevState, body: '' })); |
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.
There is a syntax error in this line. It seems like you intended to spread prevState
, but the correct syntax is { ...prevState, body: '' }
.
deleteComment(commentId).catch(() => { | ||
setError(true); | ||
}); |
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 using a try-catch block for error handling when calling deleteComment. The checklist suggests using try-catch for error handling, which can provide more control over error management.
getPostComments(post.id) | ||
.then(setComments) | ||
.catch(() => setError(true)) | ||
.finally(() => setIsLoading(false)); |
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 using a try-catch block for error handling when calling getPostComments. The checklist suggests using try-catch for error handling, which can provide more control over error management.