Skip to content

Conversation

@Bohdan259
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.

Review Summary

Great work on this counter application! I'm happy to approve your solution as it meets all the requirements. Your use of functional updates with setCount is excellent practice, ensuring state updates are reliable.

As a small suggestion for future improvement, you can make your event handlers a bit cleaner. For example, in your buttons, you're using onClick={() => addOne(count)}. Since the addOne function doesn't take any parameters and already has access to the count state, you can simplify this to just onClick={addOne}. This is a minor point but is a more common and concise pattern in React.

Keep up the great work!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

<button
type="button"
className="App__add-one"
onClick={() => addOne(count)}

Choose a reason for hiding this comment

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

The addOne function is defined without any parameters, so passing count here is unnecessary. The function can access the count state variable directly from its closure. This also applies to the onClick handlers for the other two buttons. You can simplify this call to onClick={addOne}.

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