Skip to content

Instantly share code, notes, and snippets.

@tfiechowski
Last active January 9, 2021 00:21
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 tfiechowski/f0403d045a659c8a13a2f6bb74c7dbc7 to your computer and use it in GitHub Desktop.
Save tfiechowski/f0403d045a659c8a13a2f6bb74c7dbc7 to your computer and use it in GitHub Desktop.
import { useState } from "react";
export function FunctionalUpdates() {
const [counter, setCounter] = useState(0);
function handleIncrement() {
setCounter(counter + 1);
}
return (
<div>
<div>Counter value: {counter}</div>
<button onClick={handleIncrement}>
Increment
</button>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment