From 0a05213aebfa9bb6bd5686815aca45c9d205e28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kiner-tang=28=E6=96=87=E8=BE=89=29?= <1127031143@qq.com> Date: Mon, 5 Jun 2023 10:48:27 +0800 Subject: [PATCH] refactor: solve statistic circular dependency issue (#42814) --- components/statistic/Statistic.tsx | 11 ++--------- components/statistic/index.tsx | 12 +++++++++++- components/statistic/interface.ts | 0 3 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 components/statistic/interface.ts diff --git a/components/statistic/Statistic.tsx b/components/statistic/Statistic.tsx index 73e1c21716..1fe537f9f9 100644 --- a/components/statistic/Statistic.tsx +++ b/components/statistic/Statistic.tsx @@ -4,9 +4,8 @@ import type { ConfigConsumerProps } from '../config-provider'; import { ConfigContext } from '../config-provider'; import Skeleton from '../skeleton'; import StatisticNumber from './Number'; -import type { FormatConfig, valueType } from './utils'; import useStyle from './style'; -import Countdown from './Countdown'; +import type { FormatConfig, valueType } from './utils'; export interface StatisticProps extends FormatConfig { prefixCls?: string; @@ -24,11 +23,7 @@ export interface StatisticProps extends FormatConfig { onMouseLeave?: React.MouseEventHandler; } -type CompoundedComponent = { - Countdown: typeof Countdown; -}; - -const Statistic: React.FC & CompoundedComponent = (props) => { +const Statistic: React.FC = (props) => { const { prefixCls: customizePrefixCls, className, @@ -91,6 +86,4 @@ if (process.env.NODE_ENV !== 'production') { Statistic.displayName = 'Statistic'; } -Statistic.Countdown = Countdown; - export default Statistic; diff --git a/components/statistic/index.tsx b/components/statistic/index.tsx index ac430bb189..6ebcd58c50 100644 --- a/components/statistic/index.tsx +++ b/components/statistic/index.tsx @@ -1,6 +1,16 @@ import type { CountdownProps } from './Countdown'; +import Countdown from './Countdown'; import type { StatisticProps } from './Statistic'; import Statistic from './Statistic'; export type { StatisticProps, CountdownProps }; -export default Statistic; + +type CompoundedComponent = { + Countdown: typeof Countdown; +}; + +export type CompoundedStatistic = typeof Statistic & CompoundedComponent; + +(Statistic as CompoundedStatistic).Countdown = Countdown; + +export default Statistic as CompoundedStatistic; diff --git a/components/statistic/interface.ts b/components/statistic/interface.ts new file mode 100644 index 0000000000..e69de29bb2