Skip to content

Commit 8e383a2

Browse files
committed
wrapping with useCallback
1 parent 052416d commit 8e383a2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/calendar/header/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,27 +108,27 @@ const CalendarHeader = forwardRef((props: CalendarHeaderProps, ref) => {
108108
onPressRight
109109
}));
110110

111-
const addMonth = () => {
111+
const addMonth = useCallback(() => {
112112
propsAddMonth?.(1);
113-
};
113+
}, [propsAddMonth]);
114114

115-
const subtractMonth = () => {
115+
const subtractMonth = useCallback(() => {
116116
propsAddMonth?.(-1);
117-
};
117+
}, [propsAddMonth]);
118118

119119
const onPressLeft = useCallback(() => {
120120
if (typeof onPressArrowLeft === 'function') {
121121
return onPressArrowLeft(subtractMonth, month);
122122
}
123123
return subtractMonth();
124-
}, [onPressArrowLeft]);
124+
}, [onPressArrowLeft, subtractMonth]);
125125

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

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

0 commit comments

Comments
 (0)