Closed ozluy closed 4 years ago
I'm also having this problem. Did you ever find a solution?
I will try to look into this a bit this week (or perhaps weekend). I'll try to add some tests (server vs client, webpack vs browserify, etc).
Thanks :) Let me know if you have trouble replicating it. I'm also going to spend some time debugging this right now. I'll let you know if I find anything.
Ah I have figured out the issue. I'm trying to use the date picker to pick a single date, rather than a range, so I only provide a startDate
prop. Behind the scenes, this sets the startDate
and endDate
options on the date selector. When the startDate
is updated later, the endDate
option stays the same. Depending on how you style the picker, it may look like there are two startDate
s.
To solve the problem, I changed my code from this:
<DateRangePicker
startDate={this.state.datetime}
singleDatePicker
onApply={this.handlePickerChange}
>
to
<DateRangePicker
startDate={this.state.datetime}
endDate={this.state.datetime}
singleDatePicker
onApply={this.handlePickerChange}
>
I'm not 100% sure this is the problem that @ozluy had, but this solves the issue for me.
@emckay - thanks for this info!!! I'm wondering if I should ever try to do a real port of the bootstrap-daterangepicker project. This lib is really a dumb wrapper around the jQuery lib, and there's got to be a better way to manage it. I'll still try to add some tests this weekend which will hopefully catch cases like this (or at least give people more examples to look at).
@emckay thanks man, the issue was indeed using singleDatePicker and only setting startDate
I'm having a similar issue. Using a singleDatePicker with startDate (tried with endDate) and it's showing me a range (highlight on the calendar). The range starts at the start date but ends at today.
closing this due to inactivity. please re-open if this is still an issue in v6.0.0 or greater
I implemented following function to set start date but React component renders two times and sets 2 different startDate. It sets both dates come from server and current date.