【发布时间】:2021-06-30 22:04:15
【问题描述】:
我需要将我的 JSX 组件 (FC) 映射到一个对象中以进行动态渲染。 到目前为止,这是我想出的:
对象接口
interface Mappings {
EC2: {
component: React.FC<{}>;
name: string;
description: string;
};
}
export enum ResourcesEnum {
EC2 = 'EC2',
S3 = 'S3',
}
同一文件中定义的映射对象:
错误消息:
Type 'Element' is not assignable to type 'FC<{}>'.
Type 'Element' provides no match for the signature
'(props: { children?: ReactNode; }, context?: any): ReactElement<any, any> | null'.
非常感谢!
【问题讨论】:
-
<EC2 />的类型是JSX.Element,所以你可以用正确的类型修改你的Mappings接口吗?
标签: javascript node.js reactjs typescript react-native