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

defaultValues with useForm call setValueAs twice, one time with invalid input #5440

Closed
avallete opened this issue Jun 1, 2021 · 0 comments
Closed
Labels
enhancement New feature or request

Comments

@avallete
Copy link

avallete commented Jun 1, 2021

Describe the bug
When using defaultValues with a field having a setValueAs function defined, setValueAs is called twice, causing the form to fail dispatching a proper value if the return of setValueAs is not a valid input for the field.

To Reproduce

  1. Go to https://codesandbox.io/s/wandering-moon-hry9x?file=/src/App.js
  2. Open the console, you'll see that "nullableDate" has been called twice using defaultValues. Once with a string, a second time with a Date object. Causing the default value to not be displayed inside the input field of type "date" (which expect a value like: "2021-01-01")
  3. Uncomment the code from line: 25-31, reload the page.
  4. setValueAs has been called once with a string as input as expected.

Codesandbox link (Required)
https://codesandbox.io/s/wandering-moon-hry9x?file=/src/App.js

@bluebill1049 bluebill1049 added the status: under investigation aware of this issue and pending for investigation label Jun 1, 2021
bluebill1049 added a commit that referenced this issue Jun 1, 2021
@bluebill1049 bluebill1049 added enhancement New feature or request and removed status: under investigation aware of this issue and pending for investigation labels Jun 1, 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
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants