Skip to content

Commit

Permalink
fix(ConfigProvider): require moment when set locale
Browse files Browse the repository at this point in the history
  • Loading branch information
泊淞 committed Dec 12, 2024
1 parent 84eb976 commit e024058
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/config-provider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 @@ -27,6 +26,13 @@ import type {
const childContextCache = new Cache();

const setMomentLocale = (locale?: { momentLocale?: string }) => {
let moment;
try {
moment = require('moment');
if (moment && moment.default && moment.default.isMoment) moment = moment.default;
} catch (e) {
// ignore
}
if (moment && moment.locale && locale) {
moment.locale(locale.momentLocale);
}
Expand Down

0 comments on commit e024058

Please sign in to comment.