Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

material ui Link onClick event type

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

like image 557
shokoEguchi Avatar asked Jun 29 '26 01:06

shokoEguchi


1 Answers

From Material UI docs example:

event: React.SyntheticEvent
like image 83
Francisco Ramírez Avatar answered Jul 01 '26 15:07

Francisco Ramírez