Making a simple registraction form in React/TS, and I'm trying to make the Enter key perform the role of clicking Next. It should do everything that the next button does, which is defined in handleClick.
function handleKeyPress(e: React.KeyboardEvent<HTMLDivElement>) {
if (e.code === "Enter") {
handleClick( // some argument here // );
}
}
function handleClick(e: React.MouseEvent<HTMLButtonElement>) {
if (!first || !last) {
return setError(true);
}
step(e, `${e.currentTarget.name}`);
updateName(e, first, last);
}
I cannot work out which argument to pass to handleClick, in order to satisfy Typescript. It requires 1 argument.
I have tried passing e: React.MouseEvent, and variations of arbitrary arguments. What am I missing here?