【发布时间】:2020-06-08 21:41:50
【问题描述】:
我写了 hoc withContext:
import React from 'react';
import permissionContext from 'context';
interface Props {
Component: () => React.Component;
}
const withContext: React.FC<Props> = Component => {
return function contextComponent(props: any) {
return (
<permissionContext.Consumer>
{context => <Component {...props} permissionContext={context} />}
</permissionContext.Consumer>
);
};
};
export default withContext;
我对“组件”道具有疑问:
JSX element type 'Component' does not have any construct or call signatures.
在另一个组件中,我看到了这个 hoc:
Argument of type 'FC<Props>' is not assignable to parameter of type 'PropsWithChildren<Props>'.
Property 'Component' is missing in type 'FC<Props>' but required in type 'Props'.
我是打字稿的新手。
【问题讨论】:
标签: reactjs typescript jsx