How is the type of the onclick event ?
Hello I have a question about the on-click method of the button, the event doesn't have a type, the type is something like this, is that the real type? it should be one type only for the event
7 Replies
You can also use
JSX.EventHandlerUnion< MouseEvent, HTMLButtonElement>
Type 'HTMLButtonElement' does not satisfy the constraint 'Event'.
that dont wokrtypically target or currentTarget is what you want. I'm typing my handles as
thats true, but this should have a type
From my exploration of the types library, I didn't find any. I found that the final type of the handler or the event is put together using various helper types in the types lib, but none of them are specifically the type of the event
If you do find one, please let me know
It might be the other way around,
JSX.EventHandlerUnion<HTMLButtonElement, MouseEvent>
You use it like this. e
will be typed properly then
that does the trick, thanks