Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useWatch on a field array of controlled components leads to unexpected behaviour [Controller] #3353

Closed
nhanpdnguyen opened this issue Nov 4, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@nhanpdnguyen
Copy link

Describe the bug
Hi everyone, I'm implementing a feature using field array with some controlled custom input (using render attribute on Controller)
Then I ran into this issue, the watchedFieldArray's newly-added item gets undefined. I noticed that this issue happens when inserting an item at an in-between index.

To Reproduce
Steps to reproduce the behavior:

  1. Go to CodeSandbox link
  2. Click Insert at index 1
  3. Watch the Console logs and see the index-1 item is undefined
  4. Click Append
  5. Watch the Console logs and see the last item is not undefined

Desired output

Codesandbox link (Required)
https://codesandbox.io/embed/unruffled-thompson-yx492?file=/src/App.js:1628-2152

Expected behavior
the index-1 item is not undefined

Desktop (please complete the following information):

  • OS: MacOS 10.15.7
  • Browser: Chrome
  • Version: 86

Additional context
If I add shouldUnregister: false option to useForm, the problem goes away

@bluebill1049
Copy link
Member

Thanks, i have created the same lol #3349 will take yourself.

@bluebill1049 bluebill1049 added the bug Something isn't working label Nov 4, 2020
@bluebill1049 bluebill1049 changed the title useWatch on a field array of controlled components leads to unexpected behaviour useWatch on a field array of controlled components leads to unexpected behaviour [Controller] Nov 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants