How to add initialVisibleMonth in DayPickerSingleDateController in react-dates?

93 views Asked by At
      <DayPickerSingleDateController
        numberOfMonths={1}
        keepOpenOnDateSelect={true}
        dayPickerNavigationInlineStyles={{ color: 'red' }}
        onDateChange={handleSinglePickerDateChange}
        focused={false}            
        date={moment(clickedDate)}
        onFocusChange={(focusedInput) => {
          console.log('focus change of DayPickerSingleDateController');
        }}
        initialVisibleMonth={() => moment(new Date('01-08-2023'))}
        isDayBlocked={getBlockedDay}
        isDayHighlighted={getHighlightedDay}
      />

In above, I'm trying to set initialVisible month of calendar to september. Is there any syntax error I'm doing here or something is buggy here?

Please help if anyone know the correct way.

1

There are 1 answers

3
Kiran Kumar On

Yes, there's syntax error, change the line from initialVisibleMonth={() => moment(new Date('01-08-2023'))} to initialVisibleMonth={ moment(new Date('01-08-2023')}