Last active
December 20, 2018 18:25
-
-
Save jamesseanwright/d86f115fac0d84c0979803ea1b5b966e to your computer and use it in GitHub Desktop.
React useState Hook Example
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
const MessageForm: React.FC<Props> = ({ submitMessage }) => { | |
const [message, setMessage] = React.useState(''); | |
return ( | |
<form onSubmit={e => { | |
e.preventDefault(); | |
submitMessage(message); | |
}}> | |
<input | |
type="text" | |
onChange={e => setMessage(e.currentTarget.value)} | |
/> | |
<input | |
type="submit" | |
value="Add" | |
/> | |
</form> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment