react-hook-form: setValue not working in the latest release
Describe the bug
setValue is not setting the form values in the latest release.
To Reproduce
- Open the codesandbox links given below
- Click the “Click Me” button in the preview
Codesandbox link (Required)
- Working 5.4.2 — https://codesandbox.io/s/festive-morse-m8cxm?file=/src/App.js
- Not Working [Latest] — https://codesandbox.io/s/winter-cdn-w8wp7?file=/src/App.js
Expected behavior Value should be set in the form
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 21 (10 by maintainers)
hey, @kamranahmedse make sure you are registered at
useEffect, otherwise, each render will refresh the registration. The latest patch introducerefcompare to avoid component unmount and remount problem.https://codesandbox.io/s/elastic-sinoussi-urxkm?file=/src/App.js
This bug is caused by this PR (https://github.com/react-hook-form/react-hook-form/pull/1412). I will fix this. The same type error caused when
FormValuesisRecord<string, any>: TypeScript Playground@bluebill1049 Sorry for the delay, i still have the same issue on new version.