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

Loading…
Cancel
Save