Last active
April 21, 2022 20:48
-
-
Save tanner-west/e51c6e8120a27f005b8c9c8212c642d6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { useState } from "react" | |
export default function StateComponent() { | |
const [counter, setCounter] = useState(0) | |
const [text, setText] = useState() | |
return ( | |
<div> | |
<p>counter: {counter}</p> | |
<p>text: {text}</p> | |
<button onClick={() => setCounter(counter + 1)}>Increment</button> | |
<br /> | |
<button onClick={() => console.log(counter)}>Log counter value</button> | |
<br /> | |
<input onChange={(e) => setText(e.target.value)} type="text"></input> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment