Counter Component

Easy
Free
#State Management

Build a counter in React: a number on the page that goes up by one when you click Increment and down by one when you click Decrement. You'll practice keeping a value in useState and changing it when a button is clicked. The starter has the page's "Count:" line and the two buttons.

Requirements

  • The "Count:" line shows the current count, which starts at 0.
  • Each click on Increment adds 1 to the count.
  • Each click on Decrement subtracts 1 from the count, so from 0 it goes to -1.

React docs

Concepts you'll practice