hypeserver / react-date-range

A React component for choosing dates and date ranges.
MIT License
2.57k stars 658 forks source link

(0 , _addYears.default) is not a function #629

Closed semihraifgurel closed 6 months ago

semihraifgurel commented 6 months ago

(0 , _addYears.default) is not a function

react-date-range not working with date-fns@3.0.1

[BUG] Bug Reproduce Steps

Codesandbox

Environment

Package Version: 1.4.0 React version: 18.2.0 Node version: Browser:

semihraifgurel commented 6 months ago

If you downgrade the version of date-fns to 2.30.0 it works.

Tembew commented 6 months ago

Been getting this past few days. Finally found that its an incompatibility with the newer date-fns. Probably because they use require("date-fns/addYears") instead of require("date-fns"). addYears is in the date-fns folder now instead of its own folder. same with other functions. Is it ok to break things like that? re date-fns devs. There's also no .default as far as I could tell.

titoadeoye commented 6 months ago

Anybody have a solution yet?

Aakashgupta2001 commented 6 months ago

Anybody have a solution yet?

install date-fns version 2.30.0, then delete your node modules, install it again and it is working for me.

titoadeoye commented 6 months ago

Anybody have a solution yet?

install date-fns version 2.30.0, then delete your node modules, install it again and it is working for me.

Thanks! It worked for me.

umakantp commented 6 months ago

Okay, I wanted to use the latest date-fns and this package was not compatible. I forked this repo and changed it to work with the latest date-fns. In case you want to use it: https://www.npmjs.com/package/@umakantp/react-date-range

keremciu commented 6 months ago

@semihraifgurel @Tembew @ty-codes @Aakashgupta2001 @umakantp

can you please try latest version? https://www.npmjs.com/package/react-date-range/v/2.0.0-alpha.3 that should be working with date-fns@3

I'd like to make it an official release after we get enough feedback

Tembew commented 6 months ago

Seems to be working for what I needed it for.

bensampaio commented 2 months ago

Works for me as well. Any plans to make this an official release instead of alpha?

fbenfraj commented 2 months ago

@semihraifgurel @Tembew @ty-codes @Aakashgupta2001 @umakantp

can you please try latest version? https://www.npmjs.com/package/react-date-range/v/2.0.0-alpha.3 that should be working with date-fns@3

I'd like to make it an official release after we get enough feedback

Thank you so much!

keremciu commented 2 months ago

I just released version 2.0.1 @bensampaio @fbenfraj @Tembew

MatheusFelipe1988 commented 1 week ago

Se você fizer o downgrade da versão do date-fns para 2.30.0, ele funcionará.

working for me, ty