Closed jsun969 closed 8 months ago
reset function is not working.
@cenxky Thx a lot! Would you like to create a PR for this?
resolved by #5
I added tests but reset
didn't pass. I'll reopen this issue.
@jsun969 Hi, adding this code to FormItem
solve the problem and the 'reset' test passes successfully. I should create a PR with these changes or you are not convinced by this solution?
The problem seems to be the one mentioned above. Antd has an internal handling of the input state, so I added a useEffect
that updates the internal state of antd every time the value of the input controlled by react-hook-form
changes.
const form = AntdForm.useFormInstance();
React.useEffect(() => {
form.setFieldValue(name, field.value);
}, [field.value]);
I should create a PR with these changes or you are not convinced by this solution?
@avegatolber That's awesome. Just create a PR for it and I'll be appreciate.
@jsun969 PR ready
Originally posted by @HiChen404 in https://github.com/jsun969/react-hook-form-antd/issues/2#issuecomment-1641280919