import React, { useMemo } from 'react'; import { View } from 'react-native'; import { MonthComponentProps } from '../componentTypes'; import { chunk, constants, fillDates } from '../helpers'; const Month = ({ Day, DayNames, MonthTitle, Week, calendarKey, dates, firstDay, hideExtraDays, horizontal, index, listWidth, locales, markedDates, month, months, onDayPress, theme, }: MonthComponentProps) => { const monthDates = useMemo( () => fillDates({ calendarKey, hideExtraDays, firstDay, dates, monthIndex: index, months, }), [hideExtraDays, calendarKey, firstDay, dates, index, months], ); const weeks = useMemo(() => chunk(monthDates, constants.weekLength), [monthDates]); const [year, monthString] = month.split('-'); return ( {weeks.map((week) => { const key = week.find(({ dayString }) => dayString)?.dayString; if (!key) return null; return ( ); })} ); }; export default React.memo(Month);