Skip to content

Instantly share code, notes, and snippets.

@bsitruk
Last active May 16, 2021 22:59
Show Gist options
  • Save bsitruk/504ac508f4a0158a77456a1d05368d5c to your computer and use it in GitHub Desktop.
Save bsitruk/504ac508f4a0158a77456a1d05368d5c to your computer and use it in GitHub Desktop.
<form
ref={formRef}
onSubmit={(e: React.SyntheticEvent) => {
e.preventDefault();
const target = e.target as typeof e.target & {
email: { value: string };
password: { value: string };
};
const email = target.email.value; // typechecks!
const password = target.password.value; // typechecks!
// etc...
}}
>
<div>
<label>
Email:
<input type="email" name="email" />
</label>
</div>
<div>
<label>
Password:
<input type="password" name="password" />
</label>
</div>
<div>
<input type="submit" value="Log in" />
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment