Select component not working with react-hook-form ref should be forward to input instead on styled box
See original GitHub issue<Select />
ref should be forward to input instead of <Box />
Expected Behavior
React-hook-form use ref to register input fields. When submitting form <Select .../>
selected value should be in the form data
Actual Behavior
Select property value is missing from data received into onSubmit function
URL, screen shot, or Codepen exhibiting the issue
https://codesandbox.io/s/amazing-driscoll-m08if
Steps to Reproduce
Fill all the fields in the form and submit
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Returning correct value using react-select and react-hook-form
Everything works fine except the returned value is coming back as the string "[object Object]" instead of the fullName property from the object....
Read more >FAQs | React Hook Form - Simple React forms validation
React Hook Form relies on uncontrolled form, which is the reason why the register function capture ref and controlled component has its re-rendering...
Read more >React Hook Form: A guide with examples - LogRocket Blog
Learn all about using forms in React with React Hook Form, including how to create and validate forms — even with third-party components....
Read more >How to create reusable form components with React Hook ...
Step 1: Create An Input Component ... The first step is to create an input component. Creating an isolated component can be a...
Read more >react-dropzone
Important: if you omit rendering an <input> and/or binding the props from getInputProps() , opening a file dialog will not be possible. Refs....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello,
You can use Controller component:
It’s not a perfect solution but it works.
Thanks so much @Alkindi42! A few tweaks to your snippet got it working for me. I’ll post my slightly modified version here (maybe a recent change to react-hook-form API is the reason for the difference):