-
Notifications
You must be signed in to change notification settings - Fork 1.7k
reactcounter_ND #1764
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
base: master
Are you sure you want to change the base?
reactcounter_ND #1764
Conversation
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
I am requesting changes because the Increase logic does not follow the required sequencing and will produce incorrect behavior in tests. In src/App.jsx, your functional updater checks divisibility against the original prev value (see the inline comment “// Check original value”), but the requirement says to first add one and then check the updated count before deciding to add 100. This means the condition must inspect the incremented value.
Critical issue to fix:
- In src/App.jsx (within the Increase handler), compute the incremented value first and then decide on the extra 100. For example:
setCount(prev => { const newCount = prev + 1; return (newCount % 5 === 0) ? newCount + 100 : newCount; }). This preserves the functional update and aligns with the requirement to base divisibility on the updated count.
Minor note:
- If you keep an inline comment, update it to reflect that the check is on the incremented value to avoid confusion.
Your button wiring and use of functional setCount look good—once you adjust the sequencing, this should meet the task requirements. Keep it up!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
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
I am requesting changes because the Increase button’s logic does not meet the required sequence and will produce the wrong output. In src/App.jsx, within the Increase handler (check the functional updater lines where you do setCount(prev => { ... })), the divisibility check is performed on prev instead of the incremented value, violating the requirement: first add 1, then if the updated count is divisible by 5, add 100. This will fail scenarios like expecting 101, 102, 103, 104, 105, 206, ... after repeated clicks.
What to fix:
- Compute the incremented value first, e.g.,
const newCount = prev + 1. - Then base the decision on
newCount % 5 === 0to returnnewCount + 100ornewCountaccordingly.
Everything else (rendering, addOne, add100, state updates) looks solid. Make this change and you should align with the task requirements and pass tests. Keep up the good work!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
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
Excellent work on this task! I am approving your solution. You've successfully implemented the logic for the Increase button, and it now correctly produces the sequence required by the task description. The code is clean, functional, and correctly handles state updates in React. This submission meets all the core requirements, well done!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.