I am new to REACT-HOOK-FORM. I have created a profile page where I need to create two separate forms. Once for "Change Password" and another for "Profile Change". I am struggling in creating two separate forms via REACT-HOOK-FORM and utilizing that for providing validations.
const { handleSubmit, errors, control, reset, setValue } = useForm({
mode: "onSubmit",
reValidateMode: "onChange",
defaultValues: "",
validateCriteriaMode: "all",
submitFocusError: true,
nativeValidation: false,
});
Do I need to perform some edits in the above code? Please help.
You need to create a copy of the "useForm" in the following way
Now basically you can create two forms under your render function like following
Now you can have two different forms on the same page validated by react-hook-form without handling too many state variables.