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 #1176

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

Conversation

RostyslavSharuiev
Copy link

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! ✨

Comment on lines +41 to +55
useEffect(() => {
if (!selectedUser) {
return;
}

setIsLoading(true);
setIsError(false);
setUserPosts([]);
setSelectedPost(null);

getPosts(selectedUser.id)
.then(setUserPosts)
.catch(() => setIsError(true))
.finally(() => setIsLoading(false));
}, [selectedUser]);

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() }));

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,

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]);

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: '' }));

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: '' }.

Comment on lines +22 to +24
deleteComment(commentId).catch(() => {
setError(true);
});

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.

Comment on lines +41 to +44
getPostComments(post.id)
.then(setComments)
.catch(() => setError(true))
.finally(() => setIsLoading(false));

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.

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.

2 participants