event type typescript react code example

Example 1: typescript onclick event type props

interface IProps_Square {
  message: string;
  onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
}

Example 2: typescript react onchange event type

type Props = {
  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
}

export Input:React.FC<Props> ({onChange}) => (
  <input type="tex" onChange={onChange} />
)

Example 3: react onclick typescript type

onClick={(event: React.MouseEvent<HTMLElement>) => {
 makeMove(ownMark, (event.target as any).index)
}}

Example 4: React Typescript form event

// onSubmit or handleSubmit
handleSubmit(eventL FormEvent<HTMLFormElement>) {

}