diff --git a/src/date-picker/DatePicker.tsx b/src/date-picker/DatePicker.tsx index c9ae371e13..c334f6e823 100644 --- a/src/date-picker/DatePicker.tsx +++ b/src/date-picker/DatePicker.tsx @@ -109,28 +109,30 @@ const DatePicker = forwardRef((originalProps, r } } // 头部快速切换 - const onJumperClick = React.useCallback(({ trigger }) => { - const monthCountMap = { date: 1, week: 1, month: 12, quarter: 12, year: 120 }; - const monthCount = monthCountMap[mode] || 0; - - const current = new Date(year, month); - - let next = null; - if (trigger === 'prev') { - next = subtractMonth(current, monthCount); - } else if (trigger === 'current') { - next = new Date(); - } else if (trigger === 'next') { - next = addMonth(current, monthCount); - } - - const nextYear = next.getFullYear(); - const nextMonth = next.getMonth(); - - setYear(nextYear); - setMonth(nextMonth); - // eslint-disable-next-line - }, []); + const onJumperClick = React.useCallback( + ({ trigger }) => { + const monthCountMap = { date: 1, week: 1, month: 12, quarter: 12, year: 120 }; + const monthCount = monthCountMap[mode] || 0; + + const current = new Date(year, month); + + let next = null; + if (trigger === 'prev') { + next = subtractMonth(current, monthCount); + } else if (trigger === 'current') { + next = new Date(); + } else if (trigger === 'next') { + next = addMonth(current, monthCount); + } + + const nextYear = next.getFullYear(); + const nextMonth = next.getMonth(); + + setYear(nextYear); + setMonth(nextMonth); + }, + [year, month, mode, setYear, setMonth], + ); // timePicker 点击 function onTimePickerChange(val: string) { diff --git a/src/date-picker/panel/PanelContent.tsx b/src/date-picker/panel/PanelContent.tsx index 79e30cfc54..66288ec5d9 100644 --- a/src/date-picker/panel/PanelContent.tsx +++ b/src/date-picker/panel/PanelContent.tsx @@ -82,8 +82,7 @@ export default function PanelContent(props: PanelContentProps) { ({ trigger }) => { onJumperClick?.({ trigger, partial }); }, - // eslint-disable-next-line - [partial], + [partial, onJumperClick], ); return (