score:11

Accepted answer

If you create a <button> and hover over onClick prop you'll get the type in the tooltip:

enter image description here

In your example code, you are creating a custom button so the types depend on the implementation of that component.

score:2

This seems like a reasonable explanation: https://rjzaworski.com/2018/10/typescript-event-handlers

React.MouseEvent

score:3

I believe the type you are looking for is React.MouseEvent, a synthetic event provided by React. More info and examples may be found here.

score:8

For typings you should have TypeScript where you can do this:

const handleBtnClick = (e: React.MouseEvent<HTMLButtonElement>) => { ... }

Please refer to this: https://fettblog.eu/typescript-react/events/

Of course, you could try it without TypeScript but is not worth it.

Hope it helps.


Related Query

More Query from same tag