Here is the code snippet...
const CountClicks = () => {
const [count, setCount] = useState(0);
return(
<div>
<p>You clicked {count} times.</p>
<button onClick={() => {setCount(count + 1)}}>
Click me
</button>
</div>
);
}
I tried <button onClick={setCount(count + 1)}> which led to the following errors being displayed:
Uncaught Error: Too many re-renders. React limits the number of renders to prevent an infinite loop.