Skip to content

Commit

Permalink
Merge pull request #1814 from wix/fix/add_missing_dep
Browse files Browse the repository at this point in the history
Fix - Adding missing dependencies to callbacks
  • Loading branch information
Inbal-Tish authored Mar 3, 2022
2 parents 1ca84dd + a2fba9a commit 3efd6a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/calendar/day/basic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ const BasicDay = (props: BasicDayProps) => {
testID
} = props;
const style = useRef(styleConstructor(theme));
const dateData = useRef(date ? xdateToData(new XDate(date)) : undefined);
const _marking = marking || {};
const isSelected = _marking.selected || state === 'selected';
const isDisabled = typeof _marking.disabled !== 'undefined' ? _marking.disabled : state === 'disabled';
Expand All @@ -61,6 +60,7 @@ const BasicDay = (props: BasicDayProps) => {
const isMultiDot = markingType === Marking.markings.MULTI_DOT;
const isMultiPeriod = markingType === Marking.markings.MULTI_PERIOD;
const isCustom = markingType === Marking.markings.CUSTOM;
const dateData = date ? xdateToData(new XDate(date)) : undefined;

const shouldDisableTouchEvent = () => {
const {disableTouchEvent} = _marking;
Expand Down Expand Up @@ -126,12 +126,12 @@ const BasicDay = (props: BasicDayProps) => {
};

const _onPress = useCallback(() => {
onPress?.(dateData.current);
}, [onPress]);
onPress?.(dateData);
}, [onPress, date]);

const _onLongPress = useCallback(() => {
onLongPress?.(dateData.current);
}, [onLongPress]);
onLongPress?.(dateData);
}, [onLongPress, date]);

const renderMarking = () => {
const {marked, dotColor, dots, periods} = _marking;
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
return onPressArrowLeft(subtractMonth, month);
}
return subtractMonth();
}, [onPressArrowLeft, subtractMonth]);
}, [onPressArrowLeft, subtractMonth, month]);

const onPressRight = useCallback(() => {
if (typeof onPressArrowRight === 'function') {
return onPressArrowRight(addMonth, month);
}
return addMonth();
}, [onPressArrowRight, addMonth]);
}, [onPressArrowRight, addMonth, month]);

const onAccessibilityAction = (event: AccessibilityActionEvent) => {
switch (event.nativeEvent.actionName) {
Expand Down

0 comments on commit 3efd6a4

Please sign in to comment.