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
00:00
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;
Expected Output
Initially: Count: 0 After clicking the button: Count: 1, Count: 2, etc.