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
DatePicker breaks with "date.clone is not a function" when "selected" date is passed down as a prop #1120
Comments
Please see #491 |
@timfisher it does not solve my issue, i also pass a moment() object: if i give it directly, it works, if i pass a moment() object as prop, it doesn't. |
The issue corresponds to #862 and a workout i used is to use a react class component instead of a stateless function as react-datepicker needs an internal state. The downside is that this way the external redux state and the internal this.state.startDate, etc needs to be reconciled somehow, but this is the question of controlled forms and redux which redux-forms answers for example. |
I just ran into the same thing, but if you use moment to parse your date back into a moment object, it works. Example:
|
A lot of the moment methods return the date string (and are no longer an object) |
I am getting the same error. Is there any specific format we need to pass as prop ? Cant we use it without moment? Help needed. |
Just found the solution for my project. Share it here if it can help :
Weird but works... |
This may help ` import 'react-datepicker/dist/react-datepicker.css'; // CSS Modules, react-datepicker-cssmodules.css class Example extends React.Component {
}` |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This has helped me solve the issue
|
Hi. you must add DateAdapter to your providers in your Module like that: import { MAT_DATE_FORMATS, DateAdapter} from '@angular/material/core' ; @NgModule({ also if you want to use custom format : @NgModule({ |
I'm still getting this same error. I'm just experimenting with code from the docs, so I'm not sure why it won't work const onChange = (dates) => { ` Getting this error: |
If I initialize a DatePicker by directly providing the selected prop as a moment object, everything works fine:
However if i try to initialize the component by passing the "selected" prop externally as a startDate prop from WrapperComponent like this:
...the DatePicker breaks by moment js, even if the startDate provided by a predefined value of the same moment() object:
What am I doing wrong? Can't I use a DatePicker in a stateless component, passing down it's props?
The text was updated successfully, but these errors were encountered: