NAME类型不能分配给'IntrinsicAttributes&IntrinsicClassAttributes

时间:2020-04-13 01:04:34

标签: reactjs typescript sharepoint spfx

目标:将状态传递给另一个组件TableData

我可以针对此错误获取一些建议:类型NAME无法分配给类型'IntrinsicAttributes&IntrinsicClassAttributes

谢谢。

代码中的错误参考:<TableData itemsData={this.state.items}></TableData>

enter image description here

import * as React from 'react';
import styles from './TtecPolicies.module.scss';
import { ITtecPoliciesProps } from './ITtecPoliciesProps';
import TableData from './TableData';
import { escape } from '@microsoft/sp-lodash-subset';
import {
  SPHttpClient,
  SPHttpClientResponse   
} from '@microsoft/sp-http';


/* ↓↓↓ interface ↓↓↓ */
export interface ITtecPoliciesState {
  items: [
    {
      Title: string;
      Conros_ProductCode: string;
      Conros_ProductDescription: string;
      Conros_ProductCountries: any;
    }];
}
/* ↑↑↑ interface ↑↑↑ */



export default class TtecPolicies extends React.Component<ITtecPoliciesProps, ITtecPoliciesState> {
  /* ↓↓↓ constructor and state ↓↓↓ */
  // public constructor(props: ITtecPoliciesProps, state: ITtecPoliciesState) 
  public constructor(props: ITtecPoliciesProps, any)
    {
      super(props);
      // this.state = {items: []};
      this.state={
        items: [
          {
            Title: "",
            Conros_ProductCode: "",
            Conros_ProductDescription: "",
            Conros_ProductCountries: ""
          }],
      };
  }
  /* ↑↑↑ constructor and state ↑↑↑ */
  public render(): React.ReactElement<ITtecPoliciesProps> {
    
    return (
      
      <div className={ styles.ttecPolicies }>
        <h2 className={styles["titulo"]}>Produtos</h2>
        <div className={styles["products-list"]}>

          return (
            <TableData itemsData={this.state.items}></TableData>
            );            
          

        </div>
      </div>

    );
  }

    /* ↓↓↓ componentDidMount ↓↓↓ */
    public componentDidMount(){
        debugger;
        this.getLinksListData();
    }
    /* ↑↑↑ componentDidMount ↑↑↑ */

    /* ↓↓↓ method to read SharePoin data ↓↓↓ */
    private async getLinksListData(): Promise<any>
    {
      const response = await this.props.spClientContext.get(`${this.props.siteUrl}/_api/web/lists/getbytitle('Conros Products')/items`, SPHttpClient.configurations.v1);
      const data = await response.json();
      this.setState({ items: data.value });        
    }
    /* ↑↑↑ method to read SharePoin data ↑↑↑ */
}

0 个答案:

没有答案