Skip to content

Instantly share code, notes, and snippets.

@rsturim
Last active January 5, 2022 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsturim/ddb9d23d407929d07adabeb05213a17c to your computer and use it in GitHub Desktop.
Save rsturim/ddb9d23d407929d07adabeb05213a17c to your computer and use it in GitHub Desktop.
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