I'm working on a button component in TypeScript and I have encountered an issue with passing the event to the submitButton function.
import * as React from 'react';
interface Props {
className?: string;
text: string;
onClick?(event: React.MouseEvent<HTMLButtonElement>): void;
type?: string;
}
const submitButton = (event: React.MouseEvent<HTMLButtonElement> , props:
Props) => {
event.preventDefault();
props.onClick(event);
};
export const ButtonComponent = (props: Props) => {
return (
<button
className={props.className}
type={props.type}
onClick={submitButton(event, props)}
>
{props.text}
</button>
);
};
How can I resolve this error message:
Argument of type 'Event' is not assignable to parameter of type 'MouseEvent'. Property 'altKey' is missing in type 'Event'.