Closed luckyguy73 closed 8 months ago
function Counter() { const [count, setCount] = useState(0); function handleClick() { setCount(count + 1); } return ( <> <h1>{count} times</h1> <button onClick={handleClick}>Add 1</button> </> ); } // propose in the handleClick function setCount(count => count + 1)
Thanks, it's fixed 👍 https://codetogo.io/how-to-use-state-with-hooks-in-react/