Skip to content

Instantly share code, notes, and snippets.

@isabellachen
Created November 20, 2019 11:43
Show Gist options
  • Save isabellachen/d2ee68f1cb19a987d76583c8604d18c7 to your computer and use it in GitHub Desktop.
Save isabellachen/d2ee68f1cb19a987d76583c8604d18c7 to your computer and use it in GitHub Desktop.
React Typescript with Event types of Form Handlers
// 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