Problem Statement
Building a counter is the classic first step for learning React. It helps you understand how dynamic data changes in the browser.
In this challenge, you will build a counter component that allows users to increase, decrease, and reset a count value.
Requirements
Functional
- Initial State: The counter must start at
0. - Increment: Clicking the "Increment" button must add
1to the current count. - Decrement: Clicking the "Decrement" button must subtract
1from the current count. - Reset: Clicking the "Reset" button must set the count back to
0. - Lower Bound: The counter must not go below
0. The "Decrement" button must be disabled when the count is0.
Non-Functional
- Keep the code clean and well-structured.
- Use meaningful class names or CSS properties to style the counter and buttons.
Concepts Tested
- Declaring component state with the
useStatehook. - Handling mouse events with the
onClickprop. - Disabling buttons conditionally using HTML attributes.
