material ui Link onClick event type

Viewed 2080

I use typescript, react redux.

In the link of material ui, the type definition of onClick event will be an error.

It seems that React.MouseEvent<HTMLAnchorElement, MouseEvent> does not match and an error occurs.

<Link component="button" onClick={(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {handleClick(event)}}>********LINK********</Link>

    const handleClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
    event.preventDefault();
  }

No error occurs with CSB.

Why am I getting an error?

I would be happy if someone could give me some advice.

■Error(VSCode, ESlint, prettier)

error

error tooltip

function

■Error contents(I'm sorry it's hard to see)

■CSB

2 Answers

Try using MouseEvent<any>. I think that should fix your problem.

Related