Browse Source

fix: fix typescript type error

fix #5578
pull/5580/head
chenshuai2144 6 years ago
parent
commit
4c36a09fce
  1. 10
      src/pages/user/login/components/Login/index.tsx

10
src/pages/user/login/components/Login/index.tsx

@ -18,7 +18,7 @@ export interface LoginProps {
className?: string;
form: FormComponentProps['form'];
onCreate?: (form?: FormComponentProps['form']) => void;
children: React.ReactElement<LoginTab>[];
children: React.ReactElement<typeof LoginTab>[];
}
interface LoginState {
@ -125,16 +125,16 @@ class Login extends Component<LoginProps, LoginState> {
render() {
const { className, children } = this.props;
const { type, tabs = [] } = this.state;
const TabChildren: React.ReactComponentElement<LoginTab>[] = [];
const TabChildren: React.ReactComponentElement<typeof LoginTab>[] = [];
const otherChildren: React.ReactElement<unknown>[] = [];
React.Children.forEach(
children,
(child: React.ReactComponentElement<LoginTab> | React.ReactElement<unknown>) => {
(child: React.ReactComponentElement<typeof LoginTab> | React.ReactElement<unknown>) => {
if (!child) {
return;
}
if (child.type.typeName === 'LoginTab') {
TabChildren.push(child as React.ReactComponentElement<LoginTab>);
if ((child.type as { typeName: string }).typeName === 'LoginTab') {
TabChildren.push(child as React.ReactComponentElement<typeof LoginTab>);
} else {
otherChildren.push(child);
}

Loading…
Cancel
Save