Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,19 @@ 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 <View key={id} style={style.current.emptyDayContainer}/>;
return <View key={key} style={style.current.emptyDayContainer}/>;
}

const dayProps = extractDayProps(props);
const dateString = toMarkingFormat(day);
const disableDaySelection = isEmpty(props.context);

return (
<View style={style.current.dayContainer} key={id}>
<View style={style.current.dayContainer} key={key}>
<Day
{...dayProps}
testID={`${testID}.day_${dateString}`}
Expand All @@ -212,19 +214,20 @@ const Calendar = (props: CalendarProps & ContextProp) => {
);
};

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) {
week.unshift(renderWeekNumber(days[days.length - 1].getWeek()));
}

return (
<View style={style.current.week} key={id}>
<View style={style.current.week} key={key}>
{week}
</View>
);
Expand All @@ -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 <View style={style.current.monthView}>{weeks}</View>;
Expand Down