简体   繁体   中英

react-dates Cannot read property 'clone' of null at new DayPicker

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

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM