Skip to content

Instantly share code, notes, and snippets.

@tanner-west
Last active April 21, 2022 20:48
Show Gist options
  • Save tanner-west/e51c6e8120a27f005b8c9c8212c642d6 to your computer and use it in GitHub Desktop.
Save tanner-west/e51c6e8120a27f005b8c9c8212c642d6 to your computer and use it in GitHub Desktop.
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