In Tab.tsx:
import React from "react";
interface Props {
title: string;
index: number;
onClick?: React.MouseEventHandler<HTMLElement>;
}
const Tab: React.FC<Props> = ({ title, onClick, index }) => {
return (
<li>
<button onClick={onClick}>
{title}
</button>
</li>
);
};
export default Tab;
Trying to use it with a named function
const changeTab = (e: MouseEvent<HTMLButtonElement>) => {
console.log(e);
};
return <Tab onClick={changeTab}></Tab>
I have tried all different combinations of the types and can not get it to work currently receiving following error:
'{ onClick: (e: MouseEvent<HTMLButtonElement, MouseEvent>) => void; }' is missing the following properties from type 'Props': title, index, active