React-Hook-Form watercooler
July 31, 2019 at 1:06amReact-Hook-Form watercooler
July 31, 2019 at 1:06amDecember 10, 2019 at 3:16pm
That would be hard in your case. Either you make your main form aware of the value of your sub-form or vice versa
// main aware of sub formfunction MainForm() {const { register, handleSubmit, getValues. reset } = useForm();const handleSubFormSubmit = data => {// do you submission here// then resetconst { name } = getValues({ nest: true });const subForm = {other: "",};reset({name,...subForm})};return (<form onSubmit={handleSubmit(console.log)}><input name="name" ref={register} /><SubForm onSubmit={handleSubFormSubmit} /></form>);}
I don't think the lib has form-scope awareness feature.
I will have to find a way because I have 30 fields or more in my form
also tried in that way and didn't work
everything get reseted
actually look like the library is form-scope aware because the
getValue
of the subform only returns the values of the subform and not the ones from the mainformfor me was weird that getValues and triggerValidatin was form-scope but no the reset
We can continue our discussion here
This conversation has been locked