React-hook-form: "Miss ref" when attempting to register a Material UI Checkbox component.

Created on 23 Sep 2019  路  3Comments  路  Source: react-hook-form/react-hook-form

Describe the bug
After following the instructions under the "Work with UI library" section of the docs, I was unable to get my Material UI form fully registered with react-hook-form due to MUI checkboxes.

When attempting to register an MUI checkbox control with inputRef={register}; I get a warning in the console Miss ref on the checkbox input and the checkbox value does not appear in the onSubmit() data object.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/solitary-wood-ir6hq
  2. Open the console.
  3. See warning.
  4. Click the Submit button on the form.
  5. See an empty Object {} in the console.

Expected behavior
There should be no warning when attempting to register a checkbox with Material UI checkbox components. The checkbox value should be available on submit.

Screenshots

Screenshot 2019-09-23 at 11 03 14

Desktop (please complete the following information):

  • OS: OSX
  • Browser: Google Chrome
  • Version: 77.0.3865.90 (Official Build) (64-bit)
not valid

Most helpful comment

@bluebill1049 - thanks for your help.

All 3 comments

hi @andrewjrhill,

name is required, please find more information in the doc: https://react-hook-form.com/api#register

Screen Shot 2019-09-23 at 9 47 18 pm

i will improve the error messsage in the next release

to Miss ref/name:

@bluebill1049 - thanks for your help.

Was this page helpful?
0 / 5 - 0 ratings