Deviopath › React

Step Counter with useReducer

Medium · Reducers

Build a counter whose state has a count (starts at 0) and a step (starts at 1). Goal: practise useReducer with one action per button.

- "Increment" adds step, "Decrement" subtracts step, but the count never goes below 0.

- "Reset" sets the count back to 0.

- The <select> changes the step (1, 5 or 10).

Show the count as <p>Count: 0</p>.

Next: Shopping Cart