Created
July 17, 2024 07:47
-
-
Save ashleyfrieze/81332cdea10b4bc5b6caded225b7ef9b to your computer and use it in GitHub Desktop.
A react form in TypeScript
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
export const EssayForm = () => { | |
const [essay, setEssay] = useState('Please write an essay about your favourite DOM element.'); | |
const changeEssay = (event) => setEssay(event.target.value); | |
const submit = (event) => { | |
alert('An essay was submitted: ' + essay); | |
event.preventDefault(); | |
}; | |
return ( | |
<form onSubmit={submit}> | |
<label> | |
Essay: | |
<textarea value={essay} onChange={changeEssay} /> | |
</label> | |
<input type="submit" value="Submit" /> | |
</form> | |
) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment