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

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

solution #1187

wants to merge 7 commits into from

Conversation

Shevchuchka
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.

Thank you for your hard work on this project! While your code generally meets the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request:

  1. Error Handling: The error handling in your code could be improved. For example, directly throwing errors in the catch block can lead to unhandled promise rejections. It's important to handle errors more gracefully, perhaps by setting an error state or notifying the user.

  2. Prop Default Values: Setting default values for props like setSelectedPost, setShowForm, and addFunction to empty functions can lead to unexpected behavior. Consider making these props required instead of providing default values.

  3. Event Handling: The onSubmit function in NewCommentForm.tsx is missing the event parameter, which is necessary for calling preventDefault() correctly.

  4. Fetch Error Handling: The getUsers call lacks error handling, which could lead to silent failures. Adding error handling will improve user feedback and prevent potential issues.

Please address these issues to ensure the functionality and reliability of your application. Keep up the great work, and don't hesitate to reach out if you need any help! 😊

✨ 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.tsx Outdated
const [showForm, setShowForm] = useState(false);

useEffect(() => {
getUsers().then(setUsers);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling for the getUsers call to manage potential errors during the fetch operation. This will help prevent silent failures and improve user feedback.

src/App.tsx Outdated

getUserPosts(selectedUser.id)
.then(setUserPosts)
.catch(() => setError(true))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling here sets a generic error state. Consider providing more detailed error information to the user to help diagnose issues more effectively.


export const NewCommentForm: React.FC<Props> = ({
buttonLoader,
addFunction = () => {},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a default value for addFunction to an empty function can lead to unexpected behavior if the prop is not provided. Consider making this prop required without a default value.

return value.trim();
};

const onSubmit = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onSubmit function is missing the event parameter. You need to include event as a parameter to use event.preventDefault() correctly.

export const PostDetails: React.FC<Props> = ({
selectedPost,
showForm,
setShowForm = () => {},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a default value for setShowForm to an empty function can lead to unexpected behavior if the prop is not provided. Consider making this prop required without a default value.

Comment on lines 56 to 57
.catch(error => {
throw error;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throwing an error directly in the catch block is not a good practice as it can lead to unhandled promise rejections. Consider handling the error more gracefully, perhaps by setting an error state or displaying a notification to the user.

userPosts,
selectedPost,
setShowForm,
setSelectedPost = () => {},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a default value for setSelectedPost to an empty function can lead to unexpected behavior if the prop is not provided. Consider making this prop required without a default value.

users,
selectedUser,
setSelectedUser,
setSelectedPost = () => {},

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting a default value for setSelectedPost to an empty function can lead to unexpected behavior if the prop is not provided. Consider making this prop required without a default value.

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
Let's improve your code
After clicking on the user, nothing happens, you need to open comments
image

Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
Let's improve your code
The comment cannot be only spaces
image

Fix the comment block position, check it on the working example
image

Add a correct type to input of email
image

Comment on lines 30 to 31
const [text, setText] = useState('');
const [textError, setTextError] = useState(false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All states must be at the beginning of the component

Copy link

@VitaliyBondarenko1982 VitaliyBondarenko1982 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Comment on lines +28 to +32
if (selectedPost && selectedPost.id === currentPost.id) {
return true;
} else {
return false;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (selectedPost && selectedPost.id === currentPost.id) {
return true;
} else {
return false;
}
return selectedPost && selectedPost.id === currentPost.id

it will be the same.

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.

4 participants