Using Controller with React-Nice-Dates datepicker
See original GitHub issueDescribe the bug I’m trying to use a date picker for selecting a booking date, using a yup schema for validation.
After selecting a date using react-nice-dates date picker, the input value is not acknowledged and the field is marked as a validation error.
To Reproduce Steps to reproduce the behaviour:
- Go to this simplified CodeSandbox demo
- Click on the input to open the date picker,
- Select a date
- Attempt to submit the form
- See validation error message
Codesandbox link Simplified CodeSandbox demo
Expected behavior The selected date value should be correctly identified as a valid input and therefore pass schema validation.
Desktop
- OS: MacOS
- Browser: I’ve tried in both Chrome & Safari
- Version: Chrome (80.0.03987.132) & Safari (12.1.1)
Additional context
- I’ve included simplified versions of validation schema and date picker components I’m using
- From what I can gather, the
ControlleronChange event is never called 🤷♂️
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
React Hook Form and React Date picker - Wrapped at Controller
TemplateReact Hook Form and React Nice Dates - Wrapped at Controller; Environmentcreate-react-app. Files. public. src. App.js. index.js. schema.js.
Read more >React custom datepicker: Step-by-step - LogRocket Blog
In this article, we'll solve the issue by building a custom React datepicker from scratch using native JavaScript Date objects.
Read more >Is it possible to use react-datepicker with react hooks forms?
How can I implement "yup" required validation with the Controller(DatePicker)? I need to display the required field message when no date is ...
Read more >React Nice Dates
React Nice Dates is composed of a set of components and utilities with different levels of abstraction that you can use to build...
Read more >react-datepicker - npm
A simple and reusable datepicker component for React. Latest version: 4.8.0, last published: 7 months ago. Start using react-datepicker in ...
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 Free
Top 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

no worries 😃 here you go: https://codesandbox.io/s/react-hook-form-and-react-nice-dates-wrapped-at-controller-qogy4
because the external component is not following standard
onChangeandvalueprops.have a read on the doc: https://react-hook-form.com/api#Controller where you can change the method and value name 😃
Oh man you are too kind! Thank you very much for your feedback. To be honest i am so glad this lib is working for you, you are definitely my target audience who is nice, kind and appreciative!