gpt4 book ai didi

reactjs - React + TypeScript 错误 : No overload matches this call

转载 作者:行者123 更新时间:2023-12-03 14:16:55 33 4
gpt4 key购买 nike

通过数组进行映射时,我收到一个巨大的错误,例如:

// Home.tsx

render() {
const { inputs, outputs, expectedOutputs } = this.state;
return (
<ContentContainer>
{inputs.map((input, i) => {
return (
<TestRow
key={i}
rowNumber={i}
xml={inputs[i].xml}
desc={inputs[i].desc}
output={outputs[i]}
expectedOutput={expectedOutputs[i]}
handleTextAreaUpdate={this.handleTextAreaUpdate}
/>
);
})}
</ContentContainer>
);
// TestRow.tsx

interface TestRowProps {
xml: string;
desc: string;
output: string;
expectedOutput: string;
rowNumber: number;
}

class TestRow extends Component<TestRowProps, {}> {
textArea: any;

错误是:

没有重载与此调用匹配。 重载 2 个中的 1 个“(props: Readonly): TestRow”,出现以下错误。

    Type '{ key: number; rowNumber: number; xml: string; desc: string; output: never; expectedOutput: string; handleTextAreaUpdate: (e: { target: { value: string; }; }, column: number, rowNumber: number) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
Property 'handleTextAreaUpdate' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
Overload 2 of 2, '(props: TestRowProps, context?: any): TestRow', gave the following error.
Type '{ key: number; rowNumber: number; xml: string; desc: string; output: never; expectedOutput: string; handleTextAreaUpdate: (e: { target: { value: string; }; }, column: number, rowNumber: number) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<TestRowProps> & Readonly<{ children?: ReactNode; }>'.
Property 'handleTextAreaUpdate' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TestRow> & Readonly<DiagramProps> & Readonly<{ children?: ReactNode; }>'

。 TS2769

最佳答案

在错误信息中,可以找到问题所在。 属性“handleTextAreaUpdate”在类型上不存在意味着您应该在TestRowProps接口(interface)中为handleTextAreaUpdate定义一个属性。

关于reactjs - React + TypeScript 错误 : No overload matches this call,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58449813/

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