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

issue: Controller's shouldUnregister prop is mutating defaultValues object #8071

Closed
1 task done
TheMoonDawg opened this issue Mar 22, 2022 · 1 comment
Closed
1 task done
Labels
bug Something isn't working

Comments

@TheMoonDawg
Copy link

TheMoonDawg commented Mar 22, 2022

Version Number

7.28.1

Codesandbox/Expo snack

https://codesandbox.io/s/new-rain-wgxvv1?file=/src/Form.js

Steps to reproduce

The shouldUnregister prop on Controller is mutating the defaultValues object used to instantiate the form.

  1. Click Toggle Form to unmount the form.
  2. Click it again to render the form.
  3. Notice that firstName is no longer populated AS WELL as the defaultValues object being mutated in the console.

Note: The shouldUnregister flag on register does not produce this bug (as noted in the code sandbox).

Expected behaviour

Controller should not be mutating the object being passed into defaultValues.

What browsers are you seeing the problem on?

Firefox

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@TheMoonDawg
Copy link
Author

Thanks so much @bluebill1049 ! 🙇🏻

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 10, 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