Build a counter component that increases the count by 1 every time a button is clicked.
EasyProblem Statement
Build a counter component that increases the count by 1 every time a button is clicked.
Sample Output
Initially: Count: 0 After clicking the button: Count: 1, Count: 2, etc.
Limits
Time: 2s · Memory: 256 MB
Code Editor
Log in to submit00:00
Try your code in this preview. Submit marks it done.
import React, { useState } from "react"; const Counter = () => { const [count, setCount] = useState(0); const handleIncrement = () => { // Increment the count state }; return ( <div> <p>Count: {count}</p> <button onClick={handleIncrement}>Increment</button> </div> ); }; export default Counter;