Any way to know if i select the start or the end of my range date?
Hi,
First, thanks for this great module :)
I would like to hide the component when a range date has been selected (keeping it open feels like a bug).
So in the onChange callback, i was expecting some information about the context (let's say something like context=startDate|endDate|actionButton), so if context is different from 'startDate' i keep it displayed, otherwise, i hide it.
Maybe there is already another way to implement that classic behavior?
Hi @JohnCoding94
Normally react-date-range controls focused range itself by the way you can control it them with focusedRange and onRangeFocusChange props. If you control it you can is it start date or end date like below.
<DateRangePicker
{...props}
focusedRange={this.state.focusedRange}
onRangeFocusChange={focusedRange=>{
const [rangeIndex, rangeStep] = focusedRange;
if(rangeStep === 0){
console.log('start date');
} else {
console.log('end date');
}
// also don't forget to set focused range
this.setState({focusedRange});
}}
/>
Feel free to ask anything if you stuck related to this topic 🙂
@mkg0 Thanks!
Maybe it's error When I select first date - I get [0,1] When I select second date - I get [0,0]