小编Cac*_*n07的帖子

与 Typescript 反应 - Type { } 缺少 type 中的以下属性

我正在尝试使用 TypeScript 学习 React,但我似乎一直遇到有点模糊的 TS 错误。

我在下面的三个文件中编写了代码,在编译和运行时可以正常工作。我只是不断收到 TypeScript 抛出的这个超级烦人的错误

“类型 '{ id: any; key: any; }' 缺少类型 'ProfileCardProps' 中的以下属性:登录名”

// 表格.tsx

import * as React from 'react';
import Axios from 'axios';

export default class Form extends React.Component<any,any>{
  constructor(props: any){
    super(props);
    this.state = { userName: ""};
  }

  handleSubmit = (event: React.FormEvent<EventTarget>): void => {
    event.preventDefault();

   //get request...
    .then(resp => {
        this.props.onSubmit(resp.data);
    console.log(resp.data);
    this.setState({userName: ''});
  };

  public render() {
    return(
      <div>
        <div className="col-sm-12">
          <form onSubmit={this.handleSubmit}>
            <label>Run lookup:<br />
              <input type="text"
                value = …
Run Code Online (Sandbox Code Playgroud)

types typescript reactjs

29
推荐指数
1
解决办法
9万
查看次数

标签 统计

reactjs ×1

types ×1

typescript ×1