Browse Source

refactor: resolve circular reference of Alert (#42801)

* refactor: resolve circular reference of Alert

* Update useMenu.tsx

fix lint

* Update component-token.tsx

fix lint

* Update index.ts

fix lint

* Update list.ts

fix lint

* Update index.ts

fix lint

* Update index.zh-CN.md

fix lint

* Update component-token.tsx

fix lint

* Update index.test.tsx

fix lint
pull/43176/head
Zack Chang 1 year ago
committed by GitHub
parent
commit
6370ca74d2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      components/alert/Alert.tsx
  2. 2
      components/alert/ErrorBoundary.tsx
  3. 15
      components/alert/index.ts

9
components/alert/index.tsx → components/alert/Alert.tsx

@ -11,7 +11,6 @@ import * as React from 'react';
import { replaceElement } from '../_util/reactNode';
import warning from '../_util/warning';
import { ConfigContext } from '../config-provider';
import ErrorBoundary from './ErrorBoundary';
// CSSINJS
import useStyle from './style';
@ -97,11 +96,7 @@ const CloseIcon: React.FC<CloseIconProps> = (props) => {
) : null;
};
type CompoundedComponent = React.FC<AlertProps> & {
ErrorBoundary: typeof ErrorBoundary;
};
const Alert: CompoundedComponent = ({
const Alert: React.FC<AlertProps> = ({
description,
prefixCls: customizePrefixCls,
message,
@ -227,8 +222,6 @@ const Alert: CompoundedComponent = ({
);
};
Alert.ErrorBoundary = ErrorBoundary;
if (process.env.NODE_ENV !== 'production') {
Alert.displayName = 'Alert';
}

2
components/alert/ErrorBoundary.tsx

@ -1,5 +1,5 @@
import * as React from 'react';
import Alert from '.';
import Alert from './Alert';
interface ErrorBoundaryProps {
message?: React.ReactNode;

15
components/alert/index.ts

@ -0,0 +1,15 @@
import type { AlertProps } from './Alert';
import InternalAlert from './Alert';
import ErrorBoundary from './ErrorBoundary';
export type { AlertProps } from './Alert';
type CompoundedComponent = React.FC<AlertProps> & {
ErrorBoundary: typeof ErrorBoundary;
};
const Alert = InternalAlert as CompoundedComponent;
Alert.ErrorBoundary = ErrorBoundary;
export default Alert;
Loading…
Cancel
Save