question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"missing ref" error from version 6.10

See original GitHub issue

Describe the bug I am using:

  • React + Typescript
  • Material-ui (@material-ui/core) for the UI
  • Material-ui-pickers (@material-ui/pickers) for the KeyboardDatePicker
  • date-fns and DateFnsUtils (@date-io/date-fns) for the picker
  • react-hook-form (of course)
  • yup and @hookform/resolvers/yup resolver.

Trying to connect a KeyboardDatePicker with the Controller component I was getting errors, so I googled and found a solution (see sandbox below), but with my version of react-hook-form (which is 6.11.3) it is not working.

The error in console says:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

This happens only with any version that is >= 6.10.0

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/react-hook-form-ref-bug-rji1w
  2. The Date input is working
  3. Update react-hook-form to any version that is >= 6.10.0
  4. See error in console

Codesandbox link (Required)

Expected behavior A clear and concise description of what you expected to happen.

Desktop (please complete the following information):

  • OS: [e.g. iOS] any
  • Browser [e.g. chrome, safari] Chrome
  • Version [e.g. 22]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bianchicommented, Dec 12, 2020

Was able to move forward just passing all props

render={props => ( autoOk ... {...props} size="small" ... )}

1reaction
kino90commented, Nov 23, 2020

Thanks, got it working with the following code

<Controller
    control={control}
    name="myDateField"
    render={({ onChange, onBlur, value, name, ref }) => (
        <KeyboardDatePicker
            autoOk
            disabled={isLoading}
            error={Boolean(errors?.myDateField)}
            format="dd/MM/yyyy"
            fullWidth={true}
            helperText={getHelperText("myDateField")}
            inputRef={ref}
            inputVariant="outlined"
            label="Date"
            name={name}
            onBlur={onBlur}
            onChange={onChange}
            size="small"
            variant="inline"
            value={value}
        />
    )}
/>

by also setting defaultValues to null to avoid “converting uncontrolled input to controlled” error 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to correct a #REF! error - Microsoft Support
The #REF! error shows when a formula refers to a cell that's not valid. This happens most often when cells that were referenced...
Read more >
How to solve the #REF! error on spreadsheets - Sheetgo Blog
The simplest way to rectify this error is to undo your actions to revert back to your original spreadsheet and find another way...
Read more >
Error NU1605 Detected package downgrade - Stack Overflow
I had a similar issue with a .netcoreapp2.2 console application. The project was building successfully. However, publishing was failing with ...
Read more >
Ajv: Another JSON Schema Validator - npm
missingRefs: handling of missing referenced schemas. Option values: true (default) - if the reference cannot be resolved during compilation the ...
Read more >
Using Amelia
In the presence of missing data, most statistical packages use ... Additionally, write.amelia() can create a “stacked” version of the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found