Form values reset to default after submit clicked #2019
-
|
To Reproduce
Codesandbox link (Required)
Expected behavior |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 5 replies
-
|
you can't just take a codesandbox (from someone else) and update to the latest version (major version) and expect it's working. especially when there are breaking changes. the codesandbox was made probably before v5, |
Beta Was this translation helpful? Give feedback.
-
|
Thanks @bluebill1049 for prompt reply. |
Beta Was this translation helpful? Give feedback.
-
|
Don't use there is a codesandbox as well: https://codesandbox.io/s/react-hook-form-v6-controller-qsd8r |
Beta Was this translation helpful? Give feedback.
-
|
I have used the It would be lovely to have a working sample with Ionic and |
Beta Was this translation helpful? Give feedback.
-
|
I've updated to v6 and apart from FormContext to FormProvider change it looked OK. But my reset in useEffect caused submit to send default values (in my case empty object) to onSubmit. |
Beta Was this translation helpful? Give feedback.
-
do you have code example? with |
Beta Was this translation helpful? Give feedback.
-
I am not sure I understand your problem @pogo19 . In my codesandbox there is no |
Beta Was this translation helpful? Give feedback.
-
Here it is: https://codepen.io/pogo19/pen/OJMzBMd?editors=0011 Note that the reset only happens with initial form rendering, not during submit ;) From another usage elsewhere in my code, I need to use that reset because I have the |
Beta Was this translation helpful? Give feedback.
-
I had a problem and it seemed to me it is similar to what I do experience after 5.x to 6.0.0 update of react-hook-form. If it is not related, I will open a new issue. |
Beta Was this translation helpful? Give feedback.
-
|
I don't think there is an issue here, I will move this into the discussion. |
Beta Was this translation helpful? Give feedback.
-
|
@pogo19 can you create a codesandbox for your problem? (keep it simple if possible) |
Beta Was this translation helpful? Give feedback.
-
|
To original question, I came into same issue. Then I figured out Controller v6 dropped onChangeName and replaced with render props, used render to connect inner input change and everything went ok |
Beta Was this translation helpful? Give feedback.

@pogo19 can you create a codesandbox for your problem? (keep it simple if possible)