diff --git a/src/calendar/index.tsx b/src/calendar/index.tsx index c2a0b3ac3..f3768557d 100644 --- a/src/calendar/index.tsx +++ b/src/calendar/index.tsx @@ -188,9 +188,11 @@ const Calendar = (props: CalendarProps & ContextProp) => { ); }; - const renderDay = (day: XDate, id: number) => { + const renderDay = (day: XDate) => { + const key = `${currentMonth.toISOString()}-${day.getDate()}`; + if (!sameMonth(day, currentMonth) && hideExtraDays) { - return ; + return ; } const dayProps = extractDayProps(props); @@ -198,7 +200,7 @@ const Calendar = (props: CalendarProps & ContextProp) => { const disableDaySelection = isEmpty(props.context); return ( - + { ); }; - const renderWeek = (days: XDate[], id: number) => { + const renderWeek = (days: XDate[]) => { const week: JSX.Element[] = []; + const key = `${currentMonth.toISOString()}-${days[0].getDate()}`; - days.forEach((day: XDate, id2: number) => { - week.push(renderDay(day, id2)); + days.forEach((day: XDate) => { + week.push(renderDay(day)); }, this); if (props.showWeekNumbers) { @@ -224,7 +227,7 @@ const Calendar = (props: CalendarProps & ContextProp) => { } return ( - + {week} ); @@ -236,7 +239,7 @@ const Calendar = (props: CalendarProps & ContextProp) => { const weeks: JSX.Element[] = []; while (days.length) { - weeks.push(renderWeek(days.splice(0, 7), weeks.length)); + weeks.push(renderWeek(days.splice(0, 7))); } return {weeks};