Untitled
unknown
plain_text
a year ago
369 B
6
Indexable
4. Identify the issue in the following component’s state management and suggest a better approach.
function Counter() {
const [count, setCount] = useState(0);
const increment = () => {
setCount(count + 1);
setCount(count + 1);
};
return (
<div>
<p>Count: {count}</p>
<button onClick={increment}>Increment</button>
</div>
);
}
Editor is loading...
Leave a Comment