Skip to content

Commit

Permalink
refactor(ConfigProvider): static reference to moment
Browse files Browse the repository at this point in the history
  • Loading branch information
泊淞 committed Dec 5, 2024
1 parent c1dd9d8 commit e37d242
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions components/config-provider/index.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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);
}
Expand Down

0 comments on commit e37d242

Please sign in to comment.