onefinestay / react-daterange-picker

Other
563 stars 209 forks source link

How to select fixed date ranges #208

Open CaptainT33mo opened 5 years ago

CaptainT33mo commented 5 years ago

I want to restrict the date ranges selection to let's say 7 Days. How can I achieve this? Is there any props for this?

AlanFoster commented 5 years ago

Hi @CaptainT33mo - you should be able to supply the maximumDate and minimumDate props:

          <DateRangePicker
            value={this.state.value}
            onSelect={this.onSelect}
            minimumDate={moment().subtract(6, 'days')}
            maximumDate={moment()}
            singleDateRange={true}
          />
CaptainT33mo commented 5 years ago

Hey @AlanFoster , thanks for the quick reply. Actually, that's not what I want. I want something like this.

I am already using minimumDate and maximumDate props and that is being used to restrict the user to select any dates prior to the minimumDate and after the maximumDate. What I exactly want is shown in the link of airbnb react-dates. If the user clicks on any date and passed a prop to restrict the selection to only 7 days then the user can only select 7 days date range, not more than that and not less than that.

Can this be possible. Or is there any function exposed from where I can set this range manually and create my own logic for that?