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

Controlled Checkbox array example #1020

Open
leesei opened this issue Oct 22, 2023 · 0 comments
Open

Controlled Checkbox array example #1020

leesei opened this issue Oct 22, 2023 · 0 comments

Comments

@leesei
Copy link

leesei commented Oct 22, 2023

When checking "A", "C", the controlled field will return ["a",null,"c"] upon submit.
https://react-hook-form.com/docs/usecontroller

Code Sandbox:
https://codesandbox.io/s/usecontroller-checkboxes-99ld4?file=/src/App.js

I improved the example using Set:
https://codesandbox.io/s/usecontroller-checkboxes-forked-dfxcln?file=/src/App.js

Background issue:
react-hook-form/react-hook-form#476

I'm not sure whether the original behavior is intentional. At least it doesn't match the behavior of uncontrolled component.
Shall Set be adopted?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant