issue: onSubmit Type Error

Version Number


Codesandbox/Expo snack

Steps to reproduce

  1. Open Codesandbox
  2. Click on ‘App.tsx’
  3. Scroll down to ‘form’ onSubmit
  4. See type error Argument of type ‘SubmitHandler’ is not assignable to parameter of type ‘SubmitHandler’.

Screenshot 2022-04-04 at 4 04 08 PM

Note: The above type error is only produced in some newer versions works fine in v7.21.0

Expected behaviour

  1. Works fine in react-hook-form@7.21.0
  2. Here is working Codesandbox
  • As far my research its cause after this commite
  • Maybe after this PR merge #7405

Please help me with this issue. If I’m doing anything wrong please let me know.

Thank you.

What browsers are you seeing the problem on?

Google Chrome

Code of Conduct

  • I agree to follow this project’s Code of Conduct

2 thoughts on “issue: onSubmit Type Error

  1. You should provide the FormValues to useForm hook


    It’s gonna fix your onSubmit TS issue.

    Now, it’s gonna surface an error with your control type in your Input component as you only pass the FieldValues type into Control and you want to use a generic instead to get the proper Control type when you pass your control to the Input.

    There’re a couple of issues with your name and defaultValues types as well.

    See this CSB for how to fix them (Check the Input.tsx file)

Comments are closed.