-
-
Couldn't load subscription status.
- Fork 202
Open
Labels
Description
Before you start - checklist
- I followed instructions in documentation written for my React-Date-Picker version
- I have checked if this bug is not already reported
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 with useRef() 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:
Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?
Steps to reproduce
- Go to https://codesandbox.io/s/react-date-picker-useref-demo-lmkhjz?file=/src/App.js
- Open console
- See Warning
- Click on the label above the date picker
- In console see ref.current is null
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
- Browser (if applicable): Firefox, Chrome
- React-Date-Picker version: 10.2.0
- React version: 18.2.0