修复编译报错 (#1709)

This commit is contained in:
吴多益 2021-03-26 14:04:40 +08:00 committed by GitHub
parent e5a27bf620
commit 7d1021b654
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -139,28 +139,27 @@ export class Badge extends React.Component<BadgeProps, object> {
}
}
export const withBadge = <P extends object>(
Component: React.ComponentType<P>
) => {
class WithBadge extends React.Component<P & BadgeProps> {
static displayName = `WithBadge(${
Component.displayName || Component.name
})`;
export function withBadge<P extends object>(Component: React.ComponentType<P>) {
return hoistNonReactStatic(
class WithBadge extends React.Component<P & BadgeProps> {
static displayName = `WithBadge(${
Component.displayName || Component.name
})`;
render() {
const badge = this.props.badge;
render() {
const badge = this.props.badge;
if (!badge) {
return <Component {...(this.props as P)} />;
if (!badge) {
return <Component {...(this.props as P)} />;
}
return (
<Badge {...(this.props as BadgeProps)}>
<Component {...(this.props as P)} />
</Badge>
);
}
return (
<Badge {...(this.props as BadgeProps)}>
<Component {...(this.props as P)} />
</Badge>
);
}
}
hoistNonReactStatic(WithBadge, Component);
return WithBadge;
};
},
Component
);
}