Skip to content

Commit 43bbd33

Browse files
committed
Calendar - getItemIndex - fix
1 parent a1c8fd1 commit 43bbd33

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/incubator/Calendar/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {FlashListPackage} from 'optionalDeps';
44
import {Constants} from '../../commons/new';
55
import {generateMonthItems} from './helpers/CalendarProcessor';
66
import {addHeaders} from './helpers/DataProcessor';
7-
import {isSameMonth, getTimestamp, addYears} from './helpers/DateUtils';
7+
import {isSameMonth, getTimestamp, addYears, getDateObject} from './helpers/DateUtils';
88
import {CalendarContextProps, CalendarProps, FirstDayOfWeek, UpdateSource, DateObjectWithOptionalDay} from './types';
99
import CalendarContext from './CalendarContext';
1010
import CalendarItem from './CalendarItem';
@@ -36,8 +36,9 @@ function Calendar(props: PropsWithChildren<CalendarProps>) {
3636

3737
const getItemIndex = useCallback((date: number) => {
3838
'worklet';
39+
const dateObject = getDateObject(date);
3940
for (let i = 0; i < items.length; i++) {
40-
if (isSameMonth(items[i], date)) {
41+
if (items[i].month === dateObject.month && items[i].year === dateObject.year) {
4142
return i;
4243
}
4344
}

0 commit comments

Comments
 (0)