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)

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)

Most upvoted comments

hey, @kamranahmedse make sure you are registered at useEffect, otherwise, each render will refresh the registration. The latest patch introduce ref compare to avoid component unmount and remount problem.

https://codesandbox.io/s/elastic-sinoussi-urxkm?file=/src/App.js

https://github.com/react-hook-form/react-hook-form/issues/1465#issuecomment-617345970

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 FormValues ​​is Record<string, any>: TypeScript Playground

@bluebill1049 Sorry for the delay, i still have the same issue on new version.