Created
November 20, 2019 11:43
-
-
Save isabellachen/d2ee68f1cb19a987d76583c8604d18c7 to your computer and use it in GitHub Desktop.
React Typescript with Event types of Form Handlers
This file contains hidden or 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
// With Bootstrap | |
const onPageNameChange = (e: React.FormEvent<FormControl & FormControlProps>) => { | |
const value = (e.target as HTMLInputElement).value; | |
updatePageName(value); | |
}; | |
const onDataSourceChange = (e: React.FormEvent<FormControl & FormControlProps>) => { | |
const value = (e.target as HTMLSelectElement).value; | |
updateChosenDataSource(value); | |
}; | |
//Without Bootstrap | |
const onPageNameChange = (e: React.FormEvent<HTMLInputElement>) => { | |
const value = (e.target as HTMLInputElement).value; | |
updatePageName(value); | |
}; | |
const onDataSourceChange = (e: React.FormEvent<HTMLSelectElement>) => { | |
const value = (e.target as HTMLSelectElement).value; | |
updateChosenDataSource(value); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment