I have problems in declaring callback for onClick property in Dropdown.Item in Typescript. What type event should be. I tried many versions without any luck. I know Dropdown.Item is rendered as an anchor and I want to do it correctly but couldn't find any way to declare type of event parameter. Please help me what type is e in my case. I'm trying MouseEvent<HTMLAnchorElement> but typescript is complaining? What correct type should I use in this place? Of course everything is inside Function Component body etc... but I just extracted my problem here...
import React, { MouseEvent } from 'react';
import { Dropdown } from 'react-bootstrap';
const handleClick = ( e: MouseEvent<HTMLAnchorElement> ) => {
e.preventDefault();
// Do something
};
<Dropdown.Item href="#" role="button" onClick={ handleClick }>
Item
</Dropdown.Item>
Typescript is complaining with this message:
Type '(e: MouseEvent<HTMLAnchorElement>) => void' is not assignable to type '(event: MouseEvent<ReplaceProps<BsPrefixComponentClass<"a", SafeAnchorProps>, BsPrefixProps<BsPrefixComponentClass<"a", SafeAnchorProps>> & DropdownItemProps>, MouseEvent>) => void'.
Types of parameters 'e' and 'event' are incompatible.
Should I put all this crazy and long declaration in my callback declaration?