Skip to content

Commit 78758ac

Browse files
committed
Passing markedDates only to items with markedDates
1 parent 210bd6a commit 78758ac

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/calendar-list/index.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,13 +287,27 @@ class CalendarList extends Component<CalendarListProps, State> {
287287
});
288288
};
289289

290+
getMarkedDatesForItem(item?: any) {
291+
const {markedDates} = this.props;
292+
293+
if (markedDates) {
294+
if (item && item.getTime) {
295+
for (const [key, value] of Object.entries(markedDates)) {
296+
if (sameMonth(new XDate(key), new XDate(item))) {
297+
return markedDates;
298+
}
299+
}
300+
}
301+
}
302+
}
303+
290304
renderItem = ({item}: any) => {
291-
const {horizontal, calendarStyle, calendarWidth, testID, markedDates, ...others} = this.props;
305+
const {horizontal, calendarStyle, calendarWidth, testID, ...others} = this.props;
292306
// NOTE: now only 'item' and 'markedDates' change for the 3 calendar (item.getTime) items
293307
return (
294308
<CalendarListItem
295309
{...others}
296-
markedDates={item.getTime ? markedDates : undefined}
310+
markedDates={this.getMarkedDatesForItem(item)}
297311
item={item}
298312
testID={`${testID}_${item}`}
299313
style={calendarStyle}

0 commit comments

Comments
 (0)