Controlled Counter
React
Junior
State managementEvent handlers
Requirements:
- Create a
Countercomponent that manages an internalcountstate starting at0. - Display the current
counton the screen. - Add a “+” button that increases
countby 1 each time it’s clicked. - Add a “–” button that decreases
countby 1 each time it’s clicked.
Note:
- Do not edit
data-testidattributes 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