Controlled Counter
React
Junior
State managementEvent handlers
Requirements:
- Create a
Counter
component that manages an internalcount
state starting at0
. - Display the current
count
on the screen. - Add a “+” button that increases
count
by 1 each time it’s clicked. - Add a “–” button that decreases
count
by 1 each time it’s clicked.
Note:
- Do not edit
data-testid
attributes on any element as they are used for testing.
import Counter from "./Counter"; export default function App() { return ( <div className="min-h-screen bg-gray-50 p-4 flex justify-center"> <Counter /> </div> ); }
JavaScript Console
console.log()statements will appear here
Tests