Created
May 9, 2022 08:24
-
-
Save adeleke5140/54078efa06044aecc77e5fb4612b8a56 to your computer and use it in GitHub Desktop.
Track the value of an input with State
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'; | |
const TrickInput = () => { | |
const [text, setText] = useState( | |
'try typing something' | |
); | |
const handleChange = event => { | |
setText(event.target.value); | |
}; | |
return ( | |
<input | |
type="text" | |
value={text} | |
onChange={handleChange} | |
/> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment