We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It would be nice to have event.target.value as a type that can be accessed.
event.target.value
The text was updated successfully, but these errors were encountered:
Hi @ersinakinci
I recommend using a type guard to add a type to the target.
<div> <input onChange={(e) => { if (e.currentTarget instanceof HTMLInputElement) { e.currentTarget.value // ... } }} /> </div>
But, indeed, it will be inconvenient, and it has the proper type with React.
@usualoma What do you think about it? Do you think we should implement it?
Sorry, something went wrong.
In React we can do something like this @yusukebe :
import { ChangeEvent } from "react"; const validateField = (event: ChangeEvent<HTMLInputElement>) { console.log(event.target.value); }
I think it's something good to implement because it was close to Dom.
As an alternative we can use type guard or type annotation:
import { ChangeEvent } from "react"; const validateField = (event: Event) { console.log((event.target as HTMLInputElement).value); }
No branches or pull requests
What is the feature you are proposing?
It would be nice to have
event.target.value
as a type that can be accessed.The text was updated successfully, but these errors were encountered: