skratchdot / react-bootstrap-daterangepicker

A date/time picker for react (using bootstrap). This is a react wrapper around the bootstrap-daterangepicker project.
http://projects.skratchdot.com/react-bootstrap-daterangepicker/
Other
474 stars 203 forks source link

How to set max date #233

Closed rafioktavian closed 3 years ago

rafioktavian commented 3 years ago

I have code

 const maxDateValue = new Date().toISOString();
<DateRangePicker
  maxDate={maxDateValue}
  autoUpdateInput={true}
  startDate={startDate}
  endDate={endDate}
  locale={{ format: "YYYY-MM-DD" }} 
  onApply={onChangeDate}>
  <input type="text" className="form-control" value={labelDate} onChange={onChangeDate} />
</DateRangePicker>

how the solution to this problem?

skratchdot commented 3 years ago

You need to change your code to use the initialSettings prop. You also need to use this component as an "uncontrolled" component: https://github.com/skratchdot/react-bootstrap-daterangepicker/#documentation