React-hook-form: Validate and submit form by clicking on an external component

Created on 21 Feb 2020  路  3Comments  路  Source: react-hook-form/react-hook-form

How can I validate and submit a form by clicking on an external component?

In the example below the form is sent without going through validation.

Codesandbox link
https://codesandbox.io/s/react-hook-form-cbc8c

question

All 3 comments

handleSubmit(onSubmit)() should be your answer. let me know if this doesn't solve your problem :)

handleSubmit(onSubmit)() should be your answer. let me know if this doesn't solve your problem :)
@bluebill1049 Thanks.
I need the event to be fired from a parent component

consider move useForm to parent component :)

Was this page helpful?
0 / 5 - 0 ratings