AlyssonBormann / github-blog-reactjs

0 stars 0 forks source link

Passing HTMLInputElement as a generic to the event type should work too: #3

Open AlyssonBormann opened 6 months ago

AlyssonBormann commented 6 months ago

This will not work if the function is called from i.e. an onChange proeperty handler reference in React code though. The react handler does not expect the type to be set for the React.ChangeEvent and will show a typing error. I had to revert to (a variant of) the selected answer instead, with a cast: (event.target as HTMLInputElement).value. – Spiralis Nov