Skip to content

Instantly share code, notes, and snippets.

@jamesseanwright
Last active December 20, 2018 18:25
Show Gist options
  • Save jamesseanwright/d86f115fac0d84c0979803ea1b5b966e to your computer and use it in GitHub Desktop.
Save jamesseanwright/d86f115fac0d84c0979803ea1b5b966e to your computer and use it in GitHub Desktop.
React useState Hook Example
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