react-dates version
[email protected]
Describe the bug
I need the Jalali calendar instead of Gregorian, so based on docs and examples, I came up with the following configuration.
The calendar works perfectly without renderMonthText prop. renderMonthText prop makes the calendar view invisible as you see on the preview below.
Source code (including props configuration)
<DayPickerSingleDateController
isRTL
renderMonthText={(month) =>
momentJalaali(month).format('jMMMM jYYYY')
}
renderDayContents={(day) => momentJalaali(day).format('jD')}
/>
Screenshots/Gifs

Desktop (please complete the following information):
Is the issue reproducible in Storybook?
https://codesandbox.io/s/purple-glade-wb9rx?file=/src/App.js
Additional context
I saw this behavior before with DateRangePicker. In that case, renderMonthText prop makes calendars invisible too.
@meness youp, seems like a bug. And I suppose it came from here:
https://github.com/airbnb/react-dates/blob/480b9902d69e64e62a2ef5c2d3b5fc3adef94444/src/components/DayPicker.jsx#L342-L346
Cause comparing two functions will be always return false, it will break UI, I can take a look and try to fix it
@meness as workaround it should work with renderMonthElement
<DayPickerSingleDateController
isRTL
renderMonthElement={({month}) =>
momentJalaali(month).format('jMMMM jYYYY')
}
renderDayContents={(day) => momentJalaali(day).format('jD')}
/>
+1 same issue here. Using the workaround in the meantime
@mmarkelov & @ljharb The issue still exists.
renderMonthText={(month) =>
DateUtils.formatDateBasedOnLocale(
month,
i18n.locale,
'MMMM YYYY',
'jMMMM jYYYY'
)
}
@meness it was not published yet
I have created a fork to fix this.
calendarSystem prop added toDateRangePicker andSingleDatePicker components for supporting JALALI calendar system.
You can see a working range picker here:
https://mohsensaremi.github.io/react-dates/?path=/story/daterangepicker-drp--non-english-locale-persian
Most helpful comment
@meness as workaround it should work with renderMonthElement