react-hook-form / documentation

📋 Official documentation
http://react-hook-form.com
MIT License
726 stars 1.04k forks source link

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

Closed ralph-p closed 10 months ago

ralph-p commented 1 year ago

https://github.com/react-hook-form/documentation/blob/981913bd1c41c478f54cf06d5c4eb854cb959d86/src/content/docs/useform.mdx#L464-L469

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);
    }}>