From 3c0d8a2d313adf000b9cd6da3389120f3e6fd275 Mon Sep 17 00:00:00 2001 From: chen_gh Date: Mon, 9 Sep 2024 15:35:25 +0800 Subject: [PATCH] fix(time-picker): error --- 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;