react-hook-form/documentation

onSubmit causing a `Error: Promise-returning function...` typescript error.

ralph-p opened this issue · 0 comments

const onSubmit = (data: IFormInput) => {
console.log(data);
};
return (
<form onSubmit={handleSubmit(onSubmit)}>

This causes a Error: Promise-returning function provided to attribute where a void return was expected. @typescript-eslint/no-misused-promises typescript error.
This change fixes the issue for me

  const onSubmit = (data: IFormInput) => {
    console.log(data)
  };
  return (
    <form onSubmit={(event) => {
        event.preventDefault();
        void handleSubmit(onSubmit)(event);
    }}>