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
v2.20.0 of date-fns seems to break react-datepicker #2870
Comments
Can confirm, after removing |
We encountered the same issue today. "v2.20.0 of date-fns seems to break react-datepicker ". it would crash the whole page. |
We are facing the exact same issue. Please provide any temporary fix till we have a permanent solution. Thanks. |
Faced with the same issue, the solution works for me - has been added locale for DatePicker component. E. g.
|
Boy, aren't the 739,604 who downloaded and installed it this week in for a surprise when their production apps all hard crash the page when someone focuses on a date picker field... |
Did anyone check what changed in v2.20 that breaks the datepicker? Would be happy to accept any PRs that fix the issue. |
Did you read my original comment? |
date-fns getWeekOfYear has changed to use TypeScript and now its options var is set up like this:
whereas before 2.20 it was this:
So since datepicker is passing null when locale is absent, the second argument isn't undefined and Perhaps date-fns should be encouraged to add the truthy check back in? |
Same issue, any feedback? |
We got the same issue in our testing environment on Friday. The below fix from @mishaseniv works for me as well. If anyone wants the English version just change 'es' to 'enUS'. Hopefully, we will get the fix soon.
|
For US English the import is from |
It looks like this should not be a problem in 3.5.0 or higher when date_utils was changed to use date-fns.getISOWeek instead of getWeek, but it would be worth tidying the call at line 200: |
Can someone confirm this works fine in v3.5.0 or higher? |
It looks like there is another break related to passing an existing date to the "selected" parameter as a string in the DatePicker component: |
Depending on your situation and which version of |
With
|
Fixed a breaking change introduced by using modern default argument value syntax (see Hacker0x01/react-datepicker#2870).
Fixed a breaking change introduced by using modern default argument value syntax (see Hacker0x01/react-datepicker#2870).
We've shipped |
Thanks @kossnocorp! |
Update dependency date-fns to v2.21.1 [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [date-fns](https://togithub.com/date-fns/date-fns) | [`2.21.0` -> `2.21.1`](https://renovatebot.com/diffs/npm/date-fns/2.21.0/2.21.1) | [![age](https://badges.renovateapi.com/packages/npm/date-fns/2.21.1/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/date-fns/2.21.1/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/date-fns/2.21.1/compatibility-slim/2.21.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/date-fns/2.21.1/confidence-slim/2.21.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>date-fns/date-fns</summary> ### [`v2.21.1`](https://togithub.com/date-fns/date-fns/blob/master/CHANGELOG.md#v2211---2021-04-15) [Compare Source](https://togithub.com/date-fns/date-fns/compare/v2.21.0...v2.21.1) Thanks to [Sasha Koss](http://github.com/kossnocorp) for working on the release. ##### Fixed - [Fixed a breaking change introduced by using modern default argument value syntax (see Hacker0x01/react-datepicker#2870) </details> --- ### Configuration :date: **Schedule**: At any time (no schedule defined). :vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied. :recycle: **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. :no_bell: **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/rust-lang/crates.io).
Can confirm |
Closing as this has been fixed. |
Thanks for fixing the issue 🎉 ! As @kossnocorp mentions, it is fixed with Thanks |
Describe the bug
We upgraded to v2.20.0 of date-fns which causes "TypeError: Cannot read property 'locale' of null". Hard to trace what actually caused this issue in date-fns - the offending call is this:
It looks as though prior to v2.20.0, the second arg to getWeek did not have a default value and now it defaults to
{}
. Since null is being passed here, that won't use the default value and further down the call stack in getWeek(), it calls getWeekYear() which assumes that options will be defaulted to {} which then causes the error.To Reproduce
Steps to reproduce the behavior:
Seems to be happening when we show the date picker. Worth mentioning that this is happening in our tests (causing failures) which uses react-testing-library and js-dom
Expected behavior
No TypeErrors should occur
The text was updated successfully, but these errors were encountered: