From 07a7aa43e78b9dc01730c4e61cfa2f379d4c2635 Mon Sep 17 00:00:00 2001 From: G_H Date: Mon, 9 Sep 2024 15:49:27 +0800 Subject: [PATCH] fix(time-picker): error (#2235) Co-authored-by: chen_gh --- src/static-past-time-picker/StaticPastTimePicker.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/static-past-time-picker/StaticPastTimePicker.tsx b/src/static-past-time-picker/StaticPastTimePicker.tsx index 55d3399840..0c6714ebe9 100644 --- a/src/static-past-time-picker/StaticPastTimePicker.tsx +++ b/src/static-past-time-picker/StaticPastTimePicker.tsx @@ -67,9 +67,13 @@ function StaticPastTimePicker({ ], [experimental, localLocale] ); - const options = useMemo(() => quickOptions || localQuickOptions, [quickOptions, localQuickOptions]); - - earliestApprove && options.push({ value: 'earliest', label: localLocale.earliestInHistory }); + const options = useMemo( + () => [ + ...(quickOptions || localQuickOptions), + ...(earliestApprove ? [{ value: 'earliest', label: localLocale.earliestInHistory }] : []), + ], + [quickOptions, localQuickOptions, earliestApprove, localLocale] + ); const parseMode = useCallback((current: string | undefined) => parseTimeMode(current, options), [options]); const originMode = (parseMode(timeRange) ?? TimeMode.Quick) as TimeMode;