Last active
January 5, 2022 22:34
-
-
Save rsturim/ddb9d23d407929d07adabeb05213a17c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from "react"; | |
export default function Counter() { | |
const [count, setCount] = useState(0); | |
return ( | |
<div> | |
<h1>Count is {count}</h1> | |
<button | |
onClick={() => { | |
setCount(count + 1); | |
}} | |
> | |
Increment | |
</button> | |
<button | |
onClick={() => { | |
setTimeout(() => { | |
setCount((prevCount) => prevCount + 1); | |
}, 1500); | |
}} | |
> | |
Increment lazy | |
</button> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment