Skip to content

Commit 3efd6a4

Browse files
authored
Merge pull request #1814 from wix/fix/add_missing_dep
Fix - Adding missing dependencies to callbacks
2 parents 1ca84dd + a2fba9a commit 3efd6a4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/calendar/day/basic/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const BasicDay = (props: BasicDayProps) => {
5252
testID
5353
} = props;
5454
const style = useRef(styleConstructor(theme));
55-
const dateData = useRef(date ? xdateToData(new XDate(date)) : undefined);
5655
const _marking = marking || {};
5756
const isSelected = _marking.selected || state === 'selected';
5857
const isDisabled = typeof _marking.disabled !== 'undefined' ? _marking.disabled : state === 'disabled';
@@ -61,6 +60,7 @@ const BasicDay = (props: BasicDayProps) => {
6160
const isMultiDot = markingType === Marking.markings.MULTI_DOT;
6261
const isMultiPeriod = markingType === Marking.markings.MULTI_PERIOD;
6362
const isCustom = markingType === Marking.markings.CUSTOM;
63+
const dateData = date ? xdateToData(new XDate(date)) : undefined;
6464

6565
const shouldDisableTouchEvent = () => {
6666
const {disableTouchEvent} = _marking;
@@ -126,12 +126,12 @@ const BasicDay = (props: BasicDayProps) => {
126126
};
127127

128128
const _onPress = useCallback(() => {
129-
onPress?.(dateData.current);
130-
}, [onPress]);
129+
onPress?.(dateData);
130+
}, [onPress, date]);
131131

132132
const _onLongPress = useCallback(() => {
133-
onLongPress?.(dateData.current);
134-
}, [onLongPress]);
133+
onLongPress?.(dateData);
134+
}, [onLongPress, date]);
135135

136136
const renderMarking = () => {
137137
const {marked, dotColor, dots, periods} = _marking;

src/calendar/header/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
121121
return onPressArrowLeft(subtractMonth, month);
122122
}
123123
return subtractMonth();
124-
}, [onPressArrowLeft, subtractMonth]);
124+
}, [onPressArrowLeft, subtractMonth, month]);
125125

126126
const onPressRight = useCallback(() => {
127127
if (typeof onPressArrowRight === 'function') {
128128
return onPressArrowRight(addMonth, month);
129129
}
130130
return addMonth();
131-
}, [onPressArrowRight, addMonth]);
131+
}, [onPressArrowRight, addMonth, month]);
132132

133133
const onAccessibilityAction = (event: AccessibilityActionEvent) => {
134134
switch (event.nativeEvent.actionName) {

0 commit comments

Comments
 (0)