0

I have below code

const [focusedInput, setFocusedInput] = useState('startDate');
const onFocusChange = fInput => {
  setFocusedInput(!fInput ? 'startDate' : fInput);
};

<DayPickerRangeController
  key={dateRange.startDate}
  startDate={dateRange.startDate}
  endDate={dateRange.endDate}
  onDatesChange={onDatesChange}
  onFocusChange={onFocusChange}
  focusedInput={focusedInput}
  numberOfMonths={2}
  isOutsideRange={day => moment().diff(day) < 0}
  initialVisibleMonth={() => dateRange.startDate}
/>

initialVisibleMonth causing the issue

Cannot read property 'clone' of null at new DayPicker

I tried googling alot but didn't find any solution. What I am trying move the calendar to first month.. like I am on dec 2020 and someone select this year, it should show the the calendar to jan 2020, This year selection is fine, I am seeing the whole year is selected in calendar just the month is not shifting to jan so that it can be visible

Any idea

Thanks

michael
  • 4,053
  • 2
  • 12
  • 31
Md. Parvez Alam
  • 4,326
  • 5
  • 48
  • 108

1 Answers1

0

You've passed a function not a value to initialVisibleMonth prop. dateRange.startDate seems like not a function, but you used it like a function.

Change

initialVisibleMonth={() => dateRange.startDate}

to

initialVisibleMonth={dateRange.startDate}
michael
  • 4,053
  • 2
  • 12
  • 31