Skip to content

Commit

Permalink
fix(DateRangePickerPanel): add necessary dependencies in useCallback (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
liyucang-git authored May 27, 2024
1 parent 0e55e26 commit bc9fedd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/date-picker/panel/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TimePickerPanel } from '../../time-picker';
import type { SinglePanelProps } from './SinglePanel';
import type { RangePanelProps } from './RangePanel';
import useConfig from '../../hooks/useConfig';
import useEventCallback from '../../hooks/useEventCallback';
import { getDefaultFormat } from '../../_common/js/date-picker/format';

export interface PanelContentProps {
Expand Down Expand Up @@ -47,15 +48,16 @@ export default function PanelContent(props: PanelContentProps) {
partial = 'start',
time,
tableData,
onMonthChange,
onYearChange,
onJumperClick,
onCellClick,
onCellMouseEnter,
onCellMouseLeave,
onTimePickerChange,
} = props;

const onMonthChange = useEventCallback(props.onMonthChange);
const onYearChange = useEventCallback(props.onYearChange);

const { timeFormat } = getDefaultFormat({ mode, format, enableTimePicker });

const showTimePicker = enableTimePicker && mode === 'date';
Expand All @@ -66,16 +68,14 @@ export default function PanelContent(props: PanelContentProps) {
(val: number) => {
onMonthChange?.(val, { partial });
},
// eslint-disable-next-line
[partial],
[partial, onMonthChange],
);

const onYearChangeInner = useCallback(
(val: number) => {
onYearChange?.(val, { partial });
},
// eslint-disable-next-line
[partial],
[partial, onYearChange],
);

const onJumperClickInner = useCallback(
Expand Down

0 comments on commit bc9fedd

Please sign in to comment.