How does react-hook-form play with the new useFormState?
Answered
Siamese Crocodile posted this in #help-forum
Siamese CrocodileOP
It seems like the two both would be doing the data tracking, but so far react-hook-form is far more advanced than useFormState. Does anyone have any examples of using the two together?
Answered by Africanized honey bee
I know this is like two months late, but for anyone that had the same question, check out this answer here: https://github.com/orgs/react-hook-form/discussions/11832#discussioncomment-9450350
As you said,
The solution in the discussion link and the linked Jack Herrington video actually ends up using both: first using the form's
It's definitely on the messier side, but it seems like the best solution right now if you are keen on using both libraries together
As you said,
react-hook-form is really nice, and plays well with other libraries like zod. On the other hand, the action prop and useFormState (now renamed useActionState) are great for progressive enhancement, allowing your form to work even when Javascript is disabled.The solution in the discussion link and the linked Jack Herrington video actually ends up using both: first using the form's
onSubmit() prop and using react-hook-form's handleSubmit() for client-side validation, and then additionally triggering a manual form submission with formRef.submit() which allows it to take advantage of server actions.It's definitely on the messier side, but it seems like the best solution right now if you are keen on using both libraries together
2 Replies
@Siamese Crocodile It seems like the two both would be doing the data tracking, but so far react-hook-form is far more advanced than useFormState. Does anyone have any examples of using the two together?
Africanized honey bee
I know this is like two months late, but for anyone that had the same question, check out this answer here: https://github.com/orgs/react-hook-form/discussions/11832#discussioncomment-9450350
As you said,
The solution in the discussion link and the linked Jack Herrington video actually ends up using both: first using the form's
It's definitely on the messier side, but it seems like the best solution right now if you are keen on using both libraries together
As you said,
react-hook-form is really nice, and plays well with other libraries like zod. On the other hand, the action prop and useFormState (now renamed useActionState) are great for progressive enhancement, allowing your form to work even when Javascript is disabled.The solution in the discussion link and the linked Jack Herrington video actually ends up using both: first using the form's
onSubmit() prop and using react-hook-form's handleSubmit() for client-side validation, and then additionally triggering a manual form submission with formRef.submit() which allows it to take advantage of server actions.It's definitely on the messier side, but it seems like the best solution right now if you are keen on using both libraries together
Answer
Siamese CrocodileOP
thats pretty cool. I'm sure someone will come alone and unify all of this into one