0
type Props = {
  onClick: (event: React.MouseEvent<HTMLInputElement>) => void
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
  onkeypress: (event: React.KeyboardEvent<HTMLInputElement>) => void
  onBlur: (event: React.FocusEvent<HTMLInputElement>) => void
  onFocus: (event: React.FocusEvent<HTMLInputElement>) => void
  onSubmit: (event: React.FormEvent<HTMLFormElement>) => void
  onClickDiv: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
}

What is this? and why is the need?

Is this only available for the React app?

boxer bb
  • 55
  • 6
  • 1
    `MouseEvent` is just a type/interface which is available under `React` namespace, your question is not about **react** though. It's about TypeScript. – M.A Shahbazi Mar 12 '22 at 14:33
  • thank you for teaching me. and I added TS tag too. – boxer bb Mar 12 '22 at 14:55
  • React is a Javascript framework, and this code looks like a definition of some event props. The component that uses these props allows you to run code when any of these events happen if you specify these props with functions. You may want to add some context about what you're trying to do. – Zip184 Mar 06 '23 at 21:48

1 Answers1

0

This is so-called SyntheticEvents. Here it is nice explanation. But shortly answering your question:

  1. They are inherited events from basic HTML elements.
  2. It is needed for cross browser-browser accessibility and manipulation with virtual DOM
  3. All top frameworks support their own implementation

And of course you could always read React Documentation.

Aaron Vasilev
  • 438
  • 2
  • 6