Open hlarcher opened 5 years ago
If I pause in DevTools here is where the script is unresponsive (line 24 of calendar.js):
Calendar.prototype = { constructor: Calendar, weekStartDate: function weekStartDate(date) { var startDate = new Date(date.getTime()); // <---- startDate = Invalid Date {}
I'm experiencing the exact same issue. For now I'm going to re-render the whole parent component as to recreate the date range picker state.
@hlarcher to do it i'm just adding a key
prop to my <DateRangePicker
set to a random value between state changes (I added a render
state and set it to render: this.state.render + 1
each time i want to reset the picker)
It's a great range picker, keep up the good job!
This supposed to be fixed in https://github.com/onefinestay/react-daterange-picker/pull/190 but the fix doesn't cover the scenario when no initialYear and initialMonth is specified. I've set up both of them to values that are outside possible data range and the picker works as expected.
<Button onClick={() => this.onExpirationDateChange(null)}>reset</Button>
<DateRangePicker
minimumDate={moment().startOf('day').toDate()}
selectionType="single"
value={this.state.expirationDateDay}
onSelect={this.onExpirationDateChange}
initialYear={moment().startOf('day').year()}
initialMonth={moment().startOf('day').month()}
/>
Is there a way to unselect / clear the date range selection?
I've tried with a custom button that sets the value in state to null and then pass that value to the value prop but it makes the browser unresponsive without yielding any errors.