Skip to content

Instantly share code, notes, and snippets.

@szaranger
Last active November 6, 2021 23:20
Show Gist options
  • Save szaranger/c1569c2313145df3fdaae9f73188bfe8 to your computer and use it in GitHub Desktop.
Save szaranger/c1569c2313145df3fdaae9f73188bfe8 to your computer and use it in GitHub Desktop.
import React, { useState} from "react";
function App() {
const [count, setCount] = useState(0);
function handleClick(){
return (setTimeout(() => {
alert("You clicked on: " + count);
}, 3000));
}
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
<button onClick={handleClick}>Show alert</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment