beginner
Building a Simple Counter with useState
Learn how to use the useState hook to manage state in a React component and handle user interactions through button clicks.
import __________... from 'react';
export default function Counter() {
const [count, setCount] = __________...;
const increment = () => {
__________...;
};
const decrement = () => {
__________...;
};
return (
<div>
<h1>Counter: {count}</h1>
<button onClick={increment}>Increment</button>
<button onClick={decrement}>Decrement</button>
</div>
);
}0/4 filled tab moves · Ctrl+↵ submits · Ctrl+Shift+↵ runsstarter code