0

This is my problem link

I am passing dynamic date array and getting month based on the current date but it is not working.

This is reference link

Harsh Patel
  • 6,334
  • 10
  • 40
  • 73

1 Answers1

3

You need to pass an array instead of function call in selectedDays and you are passing date parameter wrong in selectedDaysS function :

selectedDaysS = daysArr => {
    let dataToSend = daysArr.map(a => {
      let m = a.split('-');
      return new Date(m[0], m[1], m[2]);
    });

    return dataToSend;
  };

and inside render :

return (
      <DayPicker
        initialMonth={this.currentMonth()}
        selectedDays={this.selectedDaysS(["2019-07-25"])}
      />
    );


Here is live link : https://codesandbox.io/s/react-day-picker-examplesselected-nfbgz?fontsize=14

Shubham Verma
  • 4,918
  • 1
  • 9
  • 22