React date range highlights all dates when the value is null

122 Views Asked by At

I'm working with this library and ran into a problem. When I put endDate and startDate in the dates - null - all dates are highlighted as selected, how to solve this? By selected I mean adding spans with class .rdrInRange

can be solved in this way, but in this case, the end date is supposedly already selected, and you have to click on any date to make it the start date and not the end date, in general, a whole history of bugs. Also, if I give endDaye null and leave startDate as new Date(), then after startDate all dates will be highlighted

   const [datepicker, setDatepicker] = useState([
        {
            startDate: new Date(),
            endDate: new Date(''),
            key: 'selection',
        },
    ]);

I tried setting null for both the end date and the start date, or for both, but it didn’t help.

1

There are 1 best solutions below

0
Jethro Adamu On

I have found the solution.

setRange([
    {
      startDate: null,
      endDate: new Date(""),
      key: "selection",
    },
]);