简体   繁体   中英

How to select a default date range in react-datepicker

I'm trying to select a default value in the react-datepicker calendar. It's an inline calendar, showing 2 months, with the posibility for select a range of dates:

    <DatePicker
      inline
      monthsShown={2}
      selectsRange
      startDate={startDate}
      endDate={endDate}
      onChange={(update) => {
       setDateRange(update);
      }}
    />

However, in the documentation talks about how to select a range of dates for default but only for two DatePicker components ( https://reactdatepicker.com/#example-date-range ). I don't find how to make it just with one.

I'm new making questions if more information is needed I'll update the question. Thank you.

It's on React DatePicker Documentation

<DatePicker
  inline
  selected={startDate}
  monthsShown={2}
  selectsRange
  startDate={startDate}
  endDate={endDate}
  onChange={(update) => {
    setDateRange(update);
  }}
/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM