React-dates: Moment shouldn't be required to set the initial date

Created on 19 Jul 2018  路  4Comments  路  Source: airbnb/react-dates

I am using SingleDatePicker and wish to set the initial date. I have noticed that the date prop is required to be a moment instance. The project I am working on is using another Date library meaning that right now I have to add an entire library just to set the initial date in the picker.

Can we have the option to use at least an ISO string instead?

Happy to submit a PR for this.

Most helpful comment

We depend on moment for locale information as well; react-dates can't be used without moment.

When the Temporal proposal lands in the language, we'll switch to use that.

Thanks for responding! I completely understand the dependency for moment. I wasn't suggesting removing it entirely. @LewisYearsley and I are referring to the required prop type momentPropTypes.momentObj for certain props as mentioned here: https://github.com/airbnb/react-dates#daterangepicker
image

But your point is that since the library at the moment... depends on moment, then it's already part of your build, and you might as well use it until the Temporal proposal becomes stable. And this makes sense! 馃憤

Thanks for answering our concerns! @LewisYearsley, this can probably be closed for now?

All 4 comments

The entirety of react-dates needs moment, so you do in fact need to add the entire library regardless.

The entirety of react-dates needs moment, so you do in fact need to add the entire library regardless.

Right, but I think this poses an unnecessary restriction. Would it be possible to expose a formatter API or perhaps allow the startDate and endDate props to accept something a bit more neutral like an ISO string as @LewisYearsley suggested, and then internally, react-dates would make the conversion to a moment Object?

We depend on moment for locale information as well; react-dates can't be used without moment.

When the Temporal proposal lands in the language, we'll switch to use that.

We depend on moment for locale information as well; react-dates can't be used without moment.

When the Temporal proposal lands in the language, we'll switch to use that.

Thanks for responding! I completely understand the dependency for moment. I wasn't suggesting removing it entirely. @LewisYearsley and I are referring to the required prop type momentPropTypes.momentObj for certain props as mentioned here: https://github.com/airbnb/react-dates#daterangepicker
image

But your point is that since the library at the moment... depends on moment, then it's already part of your build, and you might as well use it until the Temporal proposal becomes stable. And this makes sense! 馃憤

Thanks for answering our concerns! @LewisYearsley, this can probably be closed for now?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thinhdd88 picture thinhdd88  路  22Comments

mccambridge picture mccambridge  路  20Comments

comron picture comron  路  22Comments

majapw picture majapw  路  25Comments

AntiFish03 picture AntiFish03  路  19Comments