Closed AdityaKallur closed 2 years ago
I got the solution for this
@AdityaKallur Can you please tell me how you achieved it? I have the same requirement
@keyurparalkar
import {defaultStaticRanges} from "react-date-range"; // this will give you already defined list import { createStaticRanges } from "react-date-range"; //pass your object to this method
let myValue= { // this is your predefined date range object
label: 'My Defined Range',
range: () => ({
startDate: pass the start date,
endDate: pass the end date
}),
};
let yourDateRange= createStaticRanges([myValue]);
<DateRangePicker className={"DateRangeWrapper"} ranges={[selectionRange]} onChange={this.handleDateRangeSelect} showSelectionPreview={true} moveRangeOnFirstSelection={false} direction="horizontal" staticRanges = {[...defaultStaticRanges, ...yourDateRange]} //combine to one array and pass it here maxDate={new Date()}
@AdityaKallur you saved my day ! Thank you !
I have to add a defined range of past 12months date range to the already existing list of defined ranges