gpt4 book ai didi

javascript - React Typescript 属性在类型/IntrinsicAttributes 和 IntrinsicClassAttributes 上不存在

转载 作者:行者123 更新时间:2023-12-04 14:24:16 31 4
gpt4 key购买 nike

TypeScript 的新手,感觉它应该非常简单,但我对语法不太满意!

非常简单的组件:

import * as React from "react";
import ControlArea from "./ControlArea";

interface IControlAreaProps {
welcome?: any;
}

export class Layout extends React.Component<IControlAreaProps> {
public render() {
return (
<ControlArea welcome="This is the control area"/>
);
}
}

我收到 TS 错误 Property 'welcome' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<ControlArea> & Readonly<{ children?: ReactNode; }>...'.

任何指向正确方向的观点都将不胜感激。

最佳答案

你在这里的错误是你将界面添加到 Layout 组件,而你应该将它们添加到 ControlArea 组件

interface IControlAreaProps {
welcome?: any
}

export default class ControlArea extends React.Component<IControlAreaProps> {
// Your ControlArea code
}

关于javascript - React Typescript 属性在类型/IntrinsicAttributes 和 IntrinsicClassAttributes 上不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48890795/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com