beginner
Interactive Counter with State and Events
Build a counter component that uses React state to track a value and event handlers to update it when buttons are clicked.
import React from 'react';
import { ________ } from 'react';
export default function Counter() {
const [count, setCount] = __________...;
const increment = () => {
setCount(count + 1);
};
const decrement = () => {
setCount(count - 1);
};
return (
<div>
<h2>Counter: {count}</h2>
<button __________...>
Increment
</button>
<button __________...>
Decrement
</button>
</div>
);
}0/4 filled tab moves · Ctrl+↵ submits · Ctrl+Shift+↵ runsstarter code