-
-
Notifications
You must be signed in to change notification settings - Fork 195
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
ref doesn't reference #622
Comments
Ref was never documented and (even sudden) lack of it can't be considered a bug. What is your use case? Focusing input? |
Thanks for the quick response. We create a label for the date picker, and when a user clicks on the label we were using ref to focus on the first input. I also have a new use I was intending to use it for, which is exposing some details about an invalid change. For example, getting the field that is invalid and it's current invalid value so I can provide a more detailed error message to the user. I'd be happy to do a PR for those if you think they are valid use cases. Either by adding support for ref, or something different. |
But |
I'm a little confused. What does "ref is a bad idea for a name here" mean? What name? And if think using ref is a bad idea, then what would UPDATE
Is that right? |
Yep that's right! Sorry if I failed to explain it clearly. |
I've opened a PR based on our discussion #625 |
It's better and easier just to provide prop like <label for="date-picker">Date:</label>
<DatePicker firstInputId="date-picker" /> It will be similar to prop But I was also looking for some |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
Before you start - checklist
Description
I'm in the process of updating to the latest version. We were previously using
^8.1.1
. Upon updating to^10.2.0
ref.current created withuseRef()
is always null. We were using the ref to focus the date picker when a user clicked the label.I've created demo using CodeSandbox that reproduces the issue https://codesandbox.io/s/react-date-picker-useref-demo-lmkhjz?file=/src/App.js
You can see in the demo by looking at the console that react is throwing a warning:
Steps to reproduce
Expected behavior
ref.current is a reference to a dom node and React doesn't throw warning
Actual behavior
ref.current is null, react throws warning
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: