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 value become empty after delete field array item #2310

Closed
michael-land opened this issue Jul 21, 2020 · 7 comments · Fixed by #2358
Closed

useWatch value become empty after delete field array item #2310

michael-land opened this issue Jul 21, 2020 · 7 comments · Fixed by #2358
Labels
bug Something isn't working

Comments

@michael-land
Copy link
Contributor

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-v6-usewatch-mjnow?file=/src/index.js
  2. Click on append
  3. Click on append
  4. Click on delete
  5. See JSON output

Expected behavior
A clear and concise description of what you expected to happen.

it should preserve value same as watch

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

@bluebill1049
Copy link
Member

you will have to do watch('xxx', fields) i am going to add a FAQ section for this.

@bluebill1049 bluebill1049 added question Further information is requested improve documentation documentation update required labels Jul 21, 2020
@bluebill1049 bluebill1049 self-assigned this Jul 23, 2020
@bluebill1049
Copy link
Member

Screen Shot 2020-07-23 at 6 40 49 pm

doc is updated under useFieldArray.

@michael-land
Copy link
Contributor Author

michael-land commented Jul 23, 2020

Should we also mention use watch instead of useWatch when watching field array under useWatch section? @bluebill1049

This issue was about useWatch and watch behave inconsistent when watching array field.

@bluebill1049 bluebill1049 reopened this Jul 23, 2020
@bluebill1049
Copy link
Member

will do.

@bluebill1049 bluebill1049 removed the question Further information is requested label Jul 23, 2020
@bluebill1049
Copy link
Member

@xiaoyu-tamu actually would you be able to adjust the doc? as you probably can describe better? you can leave it here or send a PR, i will get it updated.

@michael-land
Copy link
Contributor Author

I would love to do, but I still don't understand why useWatch does not work for array field :-)

@bluebill1049
Copy link
Member

oh wait, sorry i miss look the issue with watch API, i will take a look at it.

@bluebill1049 bluebill1049 added status: under investigation aware of this issue and pending for investigation bug Something isn't working and removed improve documentation documentation update required status: under investigation aware of this issue and pending for investigation labels Jul 25, 2020
bluebill1049 added a commit that referenced this issue Jul 25, 2020
* fix #2310 useWatch with useFieldArray delete

* fix e2e issue

* fix issue caught by automation

* update unit test
@bluebill1049 bluebill1049 removed their assignment Aug 12, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 11, 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

Successfully merging a pull request may close this issue.

2 participants