From b7e51de4520e880d2b9593546c834ee3eab4aed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=8A=E6=B7=9E?= Date: Wed, 4 Dec 2024 13:57:40 +0800 Subject: [PATCH] refactor(ConfigProvider): static reference to moment --- components/config-provider/index.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/components/config-provider/index.tsx b/components/config-provider/index.tsx index 3b5dc73dc7..4f57b1933a 100644 --- a/components/config-provider/index.tsx +++ b/components/config-provider/index.tsx @@ -1,6 +1,7 @@ import { Component, Children, type ReactNode } from 'react'; import PropTypes from 'prop-types'; import { polyfill } from 'react-lifecycles-compat'; +import moment from 'moment'; import getContextProps from './get-context-props'; import { config, @@ -25,16 +26,7 @@ import type { const childContextCache = new Cache(); -const setMomentLocale = async (locale?: { momentLocale?: string }) => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - let moment: any; - try { - moment = await import('moment'); - if (moment && moment.default && moment.default.isMoment) moment = moment.default; - } catch (e) { - // ignore - } - +const setMomentLocale = (locale?: { momentLocale?: string }) => { if (moment && moment.locale && locale) { moment.locale(locale.momentLocale); }